feat(polybar): update polybar style

This commit is contained in:
Anhgelus Morhtuuzh 2023-07-25 23:46:05 +02:00
parent 9f00495503
commit c57e8ab185
No known key found for this signature in database
GPG key ID: 7765EC9C8383805F
604 changed files with 86703 additions and 181 deletions

View file

@ -0,0 +1,117 @@
#!/usr/bin/bash
#
# checkupdates: Safely print a list of pending updates.
#
# Copyright (c) 2013 Kyle Keen <keenerd@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
declare -r myname='checkupdates'
declare -r myver='1.0.0'
plain() {
(( QUIET )) && return
local mesg=$1; shift
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
}
msg() {
(( QUIET )) && return
local mesg=$1; shift
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
}
msg2() {
(( QUIET )) && return
local mesg=$1; shift
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
}
ask() {
local mesg=$1; shift
printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&1
}
warning() {
local mesg=$1; shift
printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
error() {
local mesg=$1; shift
printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
# check if messages are to be printed using color
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
if [[ -t 2 && ! $USE_COLOR = "n" ]]; then
# prefer terminal safe colored and bold text when tput is supported
if tput setaf 0 &>/dev/null; then
ALL_OFF="$(tput sgr0)"
BOLD="$(tput bold)"
BLUE="${BOLD}$(tput setaf 4)"
GREEN="${BOLD}$(tput setaf 2)"
RED="${BOLD}$(tput setaf 1)"
YELLOW="${BOLD}$(tput setaf 3)"
else
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
BLUE="${BOLD}\e[1;34m"
GREEN="${BOLD}\e[1;32m"
RED="${BOLD}\e[1;31m"
YELLOW="${BOLD}\e[1;33m"
fi
fi
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
if (( $# > 0 )); then
echo "${myname} v${myver}"
echo
echo "Safely print a list of pending updates"
echo
echo "Usage: ${myname}"
echo
echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.'
exit 0
fi
if ! type -P fakeroot >/dev/null; then
error 'Cannot find the fakeroot binary.'
exit 1
fi
if [[ -z $CHECKUPDATES_DB ]]; then
CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/"
fi
trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT
DBPath="$(pacman-conf DBPath)"
if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then
DBPath="/var/lib/pacman/"
fi
mkdir -p "$CHECKUPDATES_DB"
ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null
if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then
error 'Cannot fetch updates'
exit 1
fi
pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
exit 0
# vim: set noet:

View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
FILE="$HOME/.config/polybar/blocks/scripts/rofi/colors.rasi"
# random accent color
COLORS=('#EC7875' '#EC6798' '#BE78D1' '#75A4CD' '#00C7DF' '#00B19F' '#61C766' \
'#B9C244' '#EBD369' '#EDB83F' '#E57C46' '#AC8476' '#6C77BB' '#6D8895')
AC="${COLORS[$(( $RANDOM % 14 ))]}"
sed -i -e "s/ac: .*/ac: ${AC}FF;/g" $FILE
sed -i -e "s/se: .*/se: ${AC}40;/g" $FILE
rofi -no-config -no-lazy-grab -show drun -modi drun -theme ~/.config/polybar/blocks/scripts/rofi/launcher.rasi

View file

@ -0,0 +1,95 @@
#!/usr/bin/env bash
## Author : Aditya Shakya
## Mail : adi1090x@gmail.com
## Github : @adi1090x
## Twitter : @adi1090x
dir="~/.config/polybar/blocks/scripts/rofi"
uptime=$(uptime -p | sed -e 's/up //g')
rofi_command="rofi -no-config -theme $dir/powermenu.rasi"
# Options
shutdown=" Shutdown"
reboot=" Restart"
lock=" Lock"
suspend=" Sleep"
logout=" Logout"
# Confirmation
confirm_exit() {
rofi -dmenu\
-no-config\
-i\
-no-fixed-num-lines\
-p "Are You Sure? : "\
-theme $dir/confirm.rasi
}
# Message
msg() {
rofi -no-config -theme "$dir/message.rasi" -e "Available Options - yes / y / no / n"
}
# Variable passed to rofi
options="$lock\n$suspend\n$logout\n$reboot\n$shutdown"
chosen="$(echo -e "$options" | $rofi_command -p "Uptime: $uptime" -dmenu -selected-row 0)"
case $chosen in
$shutdown)
ans=$(confirm_exit &)
if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
systemctl poweroff
elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
exit 0
else
msg
fi
;;
$reboot)
ans=$(confirm_exit &)
if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
systemctl reboot
elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
exit 0
else
msg
fi
;;
$lock)
if [[ -f /usr/bin/i3lock ]]; then
i3lock
elif [[ -f /usr/bin/betterlockscreen ]]; then
betterlockscreen -l
fi
;;
$suspend)
ans=$(confirm_exit &)
if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
mpc -q pause
amixer set Master mute
systemctl suspend
elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
exit 0
else
msg
fi
;;
$logout)
ans=$(confirm_exit &)
if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
if [[ "$DESKTOP_SESSION" == "Openbox" ]]; then
openbox --exit
elif [[ "$DESKTOP_SESSION" == "bspwm" ]]; then
bspc quit
elif [[ "$DESKTOP_SESSION" == "i3" ]]; then
i3-msg exit
fi
elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
exit 0
else
msg
fi
;;
esac

View file

@ -0,0 +1,11 @@
/* colors */
* {
al: #00000000;
bg: #2f343fFF;
bga: #C4C7C5FF;
fga: #C4C7C5FF;
fg: #1C1E20FF;
ac: #00C7DFFF;
se: #00C7DF40;
}

View file

@ -0,0 +1,24 @@
/* Confirm Dialog */
@import "colors.rasi"
* {
background-color: @bg;
text-color: @fga;
font: "Iosevka Nerd Font 10";
}
window {
width: 210px;
padding: 25px;
border: 0px 0px 4px 0px;
border-radius: 0px;
border-color: @ac;
location: center;
y-offset: -2em;
}
entry {
expand: true;
text-color: @ac;
}

View file

@ -0,0 +1,119 @@
/*
*
* Author : Aditya Shakya
* Mail : adi1090x@gmail.com
* Github : @adi1090x
* Twitter : @adi1090x
*
*/
configuration {
font: "Iosevka Nerd Font 10";
show-icons: true;
icon-theme: "Papirus";
display-drun: "";
drun-display-format: "{name}";
disable-history: false;
fullscreen: false;
hide-scrollbar: true;
sidebar-mode: false;
}
@import "colors.rasi"
window {
transparency: "real";
background-color: @bg;
text-color: @fg;
border: 0px 0px 0px 0px;
border-color: @ac;
border-radius: 0px;
width: 550px;
location: center;
x-offset: 0;
y-offset: 0;
}
prompt {
enabled: true;
padding: 6px 7px 4px 7px;
background-color: @ac;
text-color: @fg;
font: "feather 12";
}
entry {
background-color: @al;
text-color: @fg;
placeholder-color: @fg;
expand: true;
horizontal-align: 0;
placeholder: "Search...";
padding: 6px;
blink: true;
}
inputbar {
children: [ prompt, entry ];
background-color: @bga;
text-color: @fg;
expand: false;
border: 0px;
border-radius: 0px;
border-color: @ac;
margin: 0px;
padding: 0px;
}
listview {
background-color: @al;
padding: 0px;
columns: 2;
lines: 8;
spacing: 6px;
cycle: true;
dynamic: true;
layout: vertical;
}
mainbox {
background-color: @al;
border: 0px;
border-radius: 0px;
border-color: @ac;
children: [ inputbar, listview ];
spacing: 6px;
padding: 6px;
}
element {
background-color: @al;
text-color: @fga;
orientation: horizontal;
border-radius: 0px;
padding: 3px;
}
element-icon {
background-color: transparent;
text-color: inherit;
size: 24px;
border: 0px;
}
element-text {
background-color: transparent;
text-color: inherit;
expand: true;
horizontal-align: 0;
vertical-align: 0.5;
margin: 0px 2.5px 0px 2.5px;
}
element selected {
background-color: @se;
text-color: @fga;
border: 0px 0px 0px 0px;
border-radius: 0px;
border-color: @ac;
}

View file

@ -0,0 +1,24 @@
/* Confirm Dialog */
@import "colors.rasi"
* {
background-color: @bg;
text-color: @fga;
font: "Iosevka Nerd Font 10";
}
window {
width: 320px;
padding: 25px;
border: 0px 0px 4px 0px;
border-radius: 0px;
border-color: @ac;
location: center;
y-offset: -2em;
}
entry {
expand: true;
text-color: @ac;
}

View file

@ -0,0 +1,127 @@
/*
*
* Author : Aditya Shakya
* Mail : adi1090x@gmail.com
* Github : @adi1090x
* Twitter : @adi1090x
*
*/
configuration {
font: "Iosevka Nerd Font 10";
show-icons: true;
icon-theme: "Papirus";
display-drun: "";
drun-display-format: "{name}";
disable-history: false;
fullscreen: false;
hide-scrollbar: true;
sidebar-mode: false;
}
@import "colors.rasi"
window {
transparency: "real";
background-color: @bg;
text-color: @fg;
border: 0px 0px 0px 0px;
border-color: @ac;
border-radius: 0px;
width: 400px;
location: center;
x-offset: 0;
y-offset: 0;
}
prompt {
enabled: true;
padding: 6px 7px 4px 7px;
background-color: @bga;
text-color: @fg;
}
textbox-prompt-colon {
padding: 6px 7px 4px 7px;
background-color: @ac;
text-color: @fg;
expand: false;
str: "";
font: "feather 12";
}
entry {
background-color: @al;
text-color: @fg;
placeholder-color: @fg;
expand: true;
horizontal-align: 0;
placeholder: "Search...";
padding: 6px;
blink: true;
}
inputbar {
children: [ textbox-prompt-colon, prompt ];
background-color: @bga;
text-color: @fg;
expand: false;
border: 0px;
border-radius: 0px;
border-color: @ac;
margin: 0px;
padding: 0px;
}
listview {
background-color: @al;
padding: 0px;
columns: 1;
lines: 8;
spacing: 6px;
cycle: true;
dynamic: true;
layout: vertical;
}
mainbox {
background-color: @al;
border: 0px;
border-radius: 0px;
border-color: @ac;
children: [ inputbar, listview ];
spacing: 6px;
padding: 6px;
}
element {
background-color: @al;
text-color: @fga;
orientation: horizontal;
border-radius: 0px;
padding: 3px 3px 3px -12px;
}
element-icon {
background-color: transparent;
text-color: inherit;
size: 24px;
border: 0px;
}
element-text {
background-color: transparent;
text-color: inherit;
expand: true;
horizontal-align: 0;
vertical-align: 0.5;
margin: 0px 2.5px 0px 2.5px;
}
element selected {
background-color: @se;
text-color: @fga;
border: 0px 0px 0px 0px;
border-radius: 0px;
border-color: @ac;
}

View file

@ -0,0 +1,127 @@
/*
*
* Author : Aditya Shakya
* Mail : adi1090x@gmail.com
* Github : @adi1090x
* Twitter : @adi1090x
*
*/
configuration {
font: "Iosevka Nerd Font 10";
show-icons: true;
icon-theme: "Papirus";
display-drun: "";
drun-display-format: "{name}";
disable-history: false;
fullscreen: false;
hide-scrollbar: true;
sidebar-mode: false;
}
@import "colors.rasi"
window {
transparency: "real";
background-color: @bg;
text-color: @fg;
border: 0px 0px 0px 0px;
border-color: @ac;
border-radius: 0px;
width: 300px;
location: center;
x-offset: 0;
y-offset: 0;
}
prompt {
enabled: true;
padding: 6px 7px 4px 7px;
background-color: @bga;
text-color: @fg;
}
textbox-prompt-colon {
padding: 6px 7px 4px 7px;
background-color: @ac;
text-color: @fg;
expand: false;
str: "";
font: "feather 12";
}
entry {
background-color: @al;
text-color: @fg;
placeholder-color: @fg;
expand: true;
horizontal-align: 0;
placeholder: "Search...";
padding: 6px;
blink: true;
}
inputbar {
children: [ textbox-prompt-colon, prompt ];
background-color: @bga;
text-color: @fg;
expand: false;
border: 0px;
border-radius: 0px;
border-color: @ac;
margin: 0px;
padding: 0px;
}
listview {
background-color: @al;
padding: 0px;
columns: 1;
lines: 5;
spacing: 6px;
cycle: true;
dynamic: true;
layout: vertical;
}
mainbox {
background-color: @al;
border: 0px;
border-radius: 0px;
border-color: @ac;
children: [ inputbar, listview ];
spacing: 6px;
padding: 6px;
}
element {
background-color: @al;
text-color: @fga;
orientation: horizontal;
border-radius: 0px;
padding: 3px 3px 3px -23px;
}
element-icon {
background-color: transparent;
text-color: inherit;
size: 24px;
border: 0px;
}
element-text {
background-color: transparent;
text-color: inherit;
expand: true;
horizontal-align: 0;
vertical-align: 0.5;
margin: 0px 2.5px 0px 2.5px;
}
element selected {
background-color: @se;
text-color: @fga;
border: 0px 0px 0px 0px;
border-radius: 0px;
border-color: @ac;
}

View file

@ -0,0 +1,127 @@
/*
*
* Author : Aditya Shakya
* Mail : adi1090x@gmail.com
* Github : @adi1090x
* Twitter : @adi1090x
*
*/
configuration {
font: "Iosevka Nerd Font 10";
show-icons: true;
icon-theme: "Papirus";
display-drun: "";
drun-display-format: "{name}";
disable-history: false;
fullscreen: false;
hide-scrollbar: true;
sidebar-mode: false;
}
@import "colors.rasi"
window {
transparency: "real";
background-color: @bg;
text-color: @fg;
border: 0px 0px 0px 0px;
border-color: @ac;
border-radius: 0px;
width: 300px;
location: center;
x-offset: 0;
y-offset: 0;
}
prompt {
enabled: true;
padding: 6px 7px 4px 7px;
background-color: @bga;
text-color: @fg;
}
textbox-prompt-colon {
padding: 6px 7px 4px 7px;
background-color: @ac;
text-color: @fg;
expand: false;
str: "";
font: "feather 12";
}
entry {
background-color: @al;
text-color: @fg;
placeholder-color: @fg;
expand: true;
horizontal-align: 0;
placeholder: "Search...";
padding: 6px;
blink: true;
}
inputbar {
children: [ textbox-prompt-colon, entry ];
background-color: @bga;
text-color: @fg;
expand: false;
border: 0px;
border-radius: 0px;
border-color: @ac;
margin: 0px;
padding: 0px;
}
listview {
background-color: @al;
padding: 0px;
columns: 1;
lines: 5;
spacing: 6px;
cycle: true;
dynamic: true;
layout: vertical;
}
mainbox {
background-color: @al;
border: 0px;
border-radius: 0px;
border-color: @ac;
children: [ inputbar, listview ];
spacing: 6px;
padding: 6px;
}
element {
background-color: @al;
text-color: @fga;
orientation: horizontal;
border-radius: 0px;
padding: 3px 3px 3px -23px;
}
element-icon {
background-color: transparent;
text-color: inherit;
size: 24px;
border: 0px;
}
element-text {
background-color: transparent;
text-color: inherit;
expand: true;
horizontal-align: 0;
vertical-align: 0.5;
margin: 0px 2.5px 0px 2.5px;
}
element selected {
background-color: @se;
text-color: @fga;
border: 0px 0px 0px 0px;
border-radius: 0px;
border-color: @ac;
}

View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
SDIR="$HOME/.config/polybar/blocks/scripts"
# Launch Rofi
MENU="$(rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p '' \
-theme $SDIR/rofi/styles.rasi \
<<< " Default| Nord| Gruvbox| Adapta| Cherry|")"
case "$MENU" in
*Default) "$SDIR"/styles.sh --default ;;
*Nord) "$SDIR"/styles.sh --nord ;;
*Gruvbox) "$SDIR"/styles.sh --gruvbox ;;
*Adapta) "$SDIR"/styles.sh --adapta ;;
*Cherry) "$SDIR"/styles.sh --cherry ;;
esac

View file

@ -0,0 +1,74 @@
#!/usr/bin/env bash
# Color files
PFILE="$HOME/.config/polybar/blocks/colors.ini"
RFILE="$HOME/.config/polybar/blocks/scripts/rofi/colors.rasi"
# Change colors
change_color() {
# polybar
sed -i -e "s/background = #.*/background = $BG/g" $PFILE
sed -i -e "s/background-alt = #.*/background-alt = $BGA/g" $PFILE
sed -i -e "s/foreground = #.*/foreground = $FG/g" $PFILE
sed -i -e "s/foreground-alt = #.*/foreground-alt = $FGA/g" $PFILE
sed -i -e "s/primary = #.*/primary = $AC/g" $PFILE
# rofi
cat > $RFILE <<- EOF
/* colors */
* {
al: #00000000;
bg: ${BG}FF;
bga: ${BGA}FF;
fga: ${FGA}FF;
fg: ${FG}FF;
ac: ${AC}FF;
se: ${AC}40;
}
EOF
polybar-msg cmd restart
}
if [[ $1 = "--default" ]]; then
BG="#2f343f"
BGA="#C4C7C5"
FGA="#C4C7C5"
FG="#1C1E20"
AC="#B4BC67"
change_color
elif [[ $1 = "--nord" ]]; then
BG="#3B4252"
BGA="#4C566A"
FGA="#E5E9F0"
FG="#ECEFF4"
AC="#A3BE8C"
change_color
elif [[ $1 = "--gruvbox" ]]; then
BG="#282828"
BGA="#EBDBB2"
FGA="#EBDBB2"
FG="#282828"
AC="#CC241D"
change_color
elif [[ $1 = "--adapta" ]]; then
BG="#243035"
BGA="#38444A"
FGA="#FDF6E3"
FG="#FFFFFF"
AC="#4DD0E1"
change_color
elif [[ $1 = "--cherry" ]]; then
BG="#1F1626"
BGA="#423949"
FGA="#FFFFFF"
FG="#FFFFFF"
AC="#D94085"
change_color
else
cat <<- _EOF_
No option specified, Available options:
--default --nord --gruvbox --adapta --cherry
_EOF_
fi

View file

@ -0,0 +1,45 @@
#!/usr/bin/env bash
NOTIFY_ICON=/usr/share/icons/Papirus/32x32/apps/system-software-update.svg
get_total_updates() { UPDATES=$(~/.config/polybar/blocks/scripts/checkupdates 2>/dev/null | wc -l); }
while true; do
get_total_updates
# notify user of updates
if hash notify-send &>/dev/null; then
if (( UPDATES > 50 )); then
notify-send -u critical -i $NOTIFY_ICON \
"You really need to update!!" "$UPDATES New packages"
elif (( UPDATES > 25 )); then
notify-send -u normal -i $NOTIFY_ICON \
"You should update soon" "$UPDATES New packages"
elif (( UPDATES > 2 )); then
notify-send -u low -i $NOTIFY_ICON \
"$UPDATES New packages"
fi
fi
# when there are updates available
# every 10 seconds another check for updates is done
while (( UPDATES > 0 )); do
if (( UPDATES == 1 )); then
echo "$UPDATES"
elif (( UPDATES > 1 )); then
echo "$UPDATES"
else
echo "None"
fi
sleep 10
get_total_updates
done
# when no updates are available, use a longer loop, this saves on CPU
# and network uptime, only checking once every 30 min for new updates
while (( UPDATES == 0 )); do
echo "None"
sleep 1800
get_total_updates
done
done