1
0
Fork 0

rewrite statusbar scripts for pango

This commit is contained in:
Luca Bilke 2024-02-03 17:52:33 +01:00
parent 6d6dfde1a1
commit 229a242c97
10 changed files with 74 additions and 71 deletions

25
.local/libexec/statusbar/colors Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
fgalpha="FF"
bgalpha="CC"
export big="size=40"
export verybig="size=60"
export fgblack="foreground='#15161E$fgalpha'"
export fgred="foreground='#F7768E$fgalpha'"
export fggreen="foreground='#9ECE6A$fgalpha'"
export fgorange="foreground='#E0AF68$fgalpha'"
export fgblue="foreground='#7AA2F7$fgalpha'"
export fgmagenta="foreground='#BB9AF7$fgalpha'"
export fgcyan="foreground='#7DCFFF$fgalpha'"
export fggray="foreground='#414868$fgalpha'"
export fgwhite="foreground='#C0CAF5$fgalpha'"
export bgblack="background='#15161E$bgalpha'"
export bgred="background='#F7768E$bgalpha'"
export bggreen="background='#9ECE6A$bgalpha'"
export bgorange="background='#E0AF68$bgalpha'"
export bgblue="background='#7AA2F7$bgalpha'"
export bgmagenta="background='#BB9AF7$bgalpha'"
export bgcyan="background='#7DCFFF$bgalpha'"
export bggray="background='#414868$bgalpha'"
export bgwhite="background='#C0CAF5$bgalpha'"

View File

@ -1,10 +1,5 @@
#!/bin/sh
red="\033[31m"
orange="\033[33m"
cyan="\033[36m"
green="\033[32m"
white="\033[37m"
reset="\033[0m"
. "$HOME/.local/libexec/statusbar/colors"
[ -z "$(ls /sys/class/power_supply)" ] && exit 0
@ -15,57 +10,57 @@ for battery in /sys/class/power_supply/BAT?*; do
case "$(cat "$battery/status" 2>&1)" in
"Full")
icon="󰁹"
color="$green"
color="$fggreen"
;;
"Not charging")
icon="󰁹"
color="$white"
color="$fgwhite"
;;
"Unknown")
icon="󰂑"
color="$orange"
color="$fgorange"
;;
"Charging")
icon="󰂄"
color="$cyan"
color="$fgcyan"
;;
"Discharging")
if [ "$capacity" -le 10 ]; then
icon="󰂎"
color="$red"
color="$fgred"
elif [ "$capacity" -le 20 ]; then
icon="󰁺"
color="$red"
color="$fgred"
elif [ "$capacity" -le 30 ]; then
icon="󰁻"
color="$white"
color="$fgwhite"
elif [ "$capacity" -le 40 ]; then
icon="󰁼"
color="$white"
color="$fgwhite"
elif [ "$capacity" -le 50 ]; then
icon="󰁽"
color="$white"
color="$fgwhite"
elif [ "$capacity" -le 60 ]; then
icon="󰁾"
color="$white"
color="$fgwhite"
elif [ "$capacity" -le 70 ]; then
icon="󰁿"
color="$white"
color="$fgwhite"
elif [ "$capacity" -le 80 ]; then
icon="󰂀"
color="$white"
color="$fgwhite"
elif [ "$capacity" -le 90 ]; then
icon="󰂁"
color="$white"
color="$fgwhite"
elif [ "$capacity" -le 100 ]; then
icon="󰂂"
color="$white"
color="$fgwhite"
else
icon="󰁹"
color="$white"
color="$fgwhite"
fi
;;
*) exit 1 ;;
esac
printf "%b" "$color$icon$reset $capacity"
printf "%b" "<span $color>$icon</span> $capacity"
done && printf "\\n"

View File

@ -1,11 +1,5 @@
#!/bin/sh
reset="\033[0m"
normal="\033[10m"
big="\033[11m"
red="\033[31m"
green="\033[32m"
orange="\033[33m"
. "$HOME/.local/libexec/statusbar/colors"
cache=/tmp/cpubarscache
temp=$(sensors | awk '/CPU/ {printf ("%.f°C", $2)}' | tr -d "+")
@ -13,23 +7,24 @@ temp=$(sensors | awk '/CPU/ {printf ("%.f°C", $2)}' | tr -d "+")
stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat 2>/dev/null)
[ ! -f $cache ] && echo "$stats" >"$cache"
old=$(cat "$cache")
printf "%b" "$big $normal$temp"
printf "%b" "<span $big> </span>$temp"
echo "$stats" | while read -r row; do
id=${row%% *}
rest=${row#* }
total=${rest%% *}
idle=${rest##* }
case "$(echo "$old" | awk '{if ($1 == id)
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' 2>/dev/null\
id="$id" total="$total" idle="$idle")" in
"0") printf "%b" "$green▁" ;;
"1") printf "%b" "$green▂" ;;
"2") printf "%b" "$green▃" ;;
"3") printf "%b" "$orange▄" ;;
"4") printf "%b" "$orange▅" ;;
"5") printf "%b" "$orange▆" ;;
"6" | "7" | "8") printf "%b" "$red▇" ;;
case "$(
echo "$old" |
awk '{if ($1 == id) printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
id="$id" total="$total" idle="$idle" 2>/dev/null
)" in
"0") printf "%b" "<span $fggreen>▁</span>" ;;
"1") printf "%b" "<span $fggreen>▂</span>" ;;
"2") printf "%b" "<span $fggreen>▃</span>" ;;
"3") printf "%b" "<span $fgorange>▄</span>" ;;
"4") printf "%b" "<span $fgorange>▅</span>" ;;
"5") printf "%b" "<span $fgorange>▆</span>" ;;
"6" | "7" | "8") printf "%b" "<span $fgred>▇</span>" ;;
esac
done
printf "%b" "$reset\n"
echo "$stats" >"$cache"

View File

@ -1,2 +1,3 @@
#!/bin/sh
date +'%X %x'

View File

@ -1,7 +1,5 @@
#!/bin/sh
# reset="\033[0m"
# big="\033[12m"
IFS='
'

View File

@ -1,14 +1,9 @@
#!/bin/sh
. "$HOME/.local/libexec/statusbar/colors"
# NOTE: This script takes its dwmblocks update signal as an argument so that it can refresh itself (defaults to 5)
# Options can be found at https://wttr.in/:help
reset="\033[0m"
big="\033[11m"
verybig="\033[12m"
red="\033[31m"
blue="\033[34m"
weatherfile="$XDG_CACHE_HOME/weatherreport"
emojifile="$XDG_CACHE_HOME/weatheremoji"
url="wttr.in/$FORECAST_LOCATION"
@ -30,12 +25,12 @@ readfile() {
}
output() {
readfile
printf "%b" "$verybig$emoji$reset $precipitation $big$blue$reset $(echo $highlow | cut -d" " -f1)° $big$red$reset $(echo $highlow | cut -d" " -f2)°\n"
printf "%b" "<span $verybig>$emoji</span> $precipitation <span $big $fgblue></span> $(echo "$highlow" | cut -d" " -f1)° <span $big $fgred></span> $(echo "$highlow" | cut -d" " -f2)°\n"
}
if fresh; then
output
else
getforecast && pkill -RTMIN+${1:-5} dwmblocks &
printf "%b" "$big$reset Getting Weather\n"
getforecast && pkill "-RTMIN+${1:-5}" dwmblocks &
printf "%b" "<span $big></span> Getting Weather\n"
fi

View File

@ -1,14 +1,13 @@
#!/bin/sh
shift=""
. "$HOME/.local/libexec/statusbar/colors"
reset="\033[0m"
big="\033[11m"
shift=""
if ls /sys/class/net/w*/operstate 1>/dev/null 2>&1; then
for w in /sys/class/net/w*/; do
percent="$(cat /proc/net/wireless | grep "$(basename "$(dirname $w/operstate)")" | tr -s ' ' | cut -d ' ' -f3 | tr -dc "[:digit:]")"
grep -vxq '0x1003' "$w/flags" && wifi_icon="" || wifi_icon="$(sed "s/up/󰖩/;s/down/󰖪/;s/dormant/󰤯/" $w/operstate | tr -d "[:space:]")"
printf "%b" "$shift$big$wifi_icon$reset $percent"
percent="$(grep "$(basename "$(dirname "$w/operstate")")" /proc/net/wireless | tr -s ' ' | cut -d ' ' -f3 | tr -dc "[:digit:]")"
grep -vxq '0x1003' "$w/flags" && wifi_icon="" || wifi_icon="$(sed "s/up/󰖩/;s/down/󰖪/;s/dormant/󰤯/" "$w/operstate" | tr -d "[:space:]")"
printf "%b" "$shift<span $big>$wifi_icon</span> $percent"
shift=" "
done
fi
@ -22,7 +21,7 @@ fi
if ls /sys/class/net/tun*/operstate 1>/dev/null 2>&1; then
for _ in /sys/class/net/tun*/operstate; do
printf "%b" "$shift$big󰖂$reset"
printf "%b" "$shift<span $big>󰖂</span>"
shift=" "
done
fi

View File

@ -1,7 +1,5 @@
#!/bin/sh
big="\033[11m"
reset="\033[0m"
. "$HOME/.local/libexec/statusbar/colors"
update() {
sum=0
@ -17,4 +15,4 @@ update() {
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
printf "%b%5sB %b%5sB%b" "$big$reset" "$(numfmt --to=iec "$rx")" "$big$reset" "$(numfmt --to=iec "$tx")" "\n"
printf "%b%5sB %b%5sB%b" "<span$big></span>" "$(numfmt --to=iec "$rx")" "<span $big></span>" "$(numfmt --to=iec "$tx")" "\n"

View File

@ -1,9 +1,8 @@
#!/bin/sh
. "$HOME/.local/libexec/statusbar/colors"
big="\033[11m"
reset="\033[0m"
icon=""
num="$(\xbps-install -Sun | grep -c "update")"
[ "$num" -gt 0 ] && printf "%b" "$big$icon$reset $num\n"
[ "$num" -gt 0 ] && printf "%b" "<span $big>$icon</span> $num\n"
exit 0

View File

@ -1,13 +1,11 @@
#!/bin/sh
big="\033[11m"
reset="\033[0m"
. "$HOME/.local/libexec/statusbar/colors"
pidof -x sbd-playerctl >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-playerctl" >/dev/null 2>&1 &
[ "$(playerctl status 2>&1)" = "No players found" ] && printf "%b%b" "$big" "$reset" && exit 1
[ "$(playerctl status 2>&1)" = "No players found" ] && printf "%b" "<span $big></span>" && exit 1
# song="$(playerctl metadata xesam:artist) - $(playerctl metadata xesam:title)"
song="$(playerctl metadata xesam:title) - $(playerctl metadata xesam:artist)"
[ ${#song} -gt 35 ] && song="$(printf %.35s "$song")…"
icon="$(playerctl status | sed "s/Playing//;s/Paused//;s/Stopped/󰓛/;")"
printf "%b" "$big$icon$reset $song"
printf "%b" "<span $big>$icon</span> $song"