1
0
Fork 0

statusbar cleanup

This commit is contained in:
Luca Bilke 2024-09-24 13:44:14 +02:00
commit ee74984c0d
12 changed files with 193 additions and 167 deletions

View file

@ -21,3 +21,50 @@ export bgmagenta="background='#BB9AF7$bgalpha'"
export bgcyan="background='#7DCFFF$bgalpha'" export bgcyan="background='#7DCFFF$bgalpha'"
export bggray="background='#414868$bgalpha'" export bggray="background='#414868$bgalpha'"
export bgwhite="background='#C0CAF5$bgalpha'" export bgwhite="background='#C0CAF5$bgalpha'"
meter_bar() {
# shellcheck disable=SC2194
case $1 in
9[0-9] | 100)
color="$fgred"
bar="▉"
;;
8[0-9])
color="$fgorange"
bar="█"
;;
7[0-9])
color="$fgorange"
bar="▇"
;;
6[0-9])
color="$fgorange"
bar="▆"
;;
5[0-9])
color="$fggreen"
bar="▅"
;;
4[0-9])
color="$fggreen"
bar="▄"
;;
3[0-9])
color="$fggreen"
bar="▂"
;;
2[0-9])
color="$fggreen"
bar="▂"
;;
1[0-9])
color="$fggreen"
bar="▁"
;;
0[0-9] | [0-9])
color="$fggreen"
bar=" "
;;
esac
printf "%s:%s" "${color}" "${bar}"
}

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
[ -z "$(ls /sys/class/power_supply)" ] && exit 0 [ -z "$(ls /sys/class/power_supply)" ] && exit 0

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
n_cpu=$(grep -c 'cpu[0-9]\+' /proc/stat) n_cpu=$(grep -c 'cpu[0-9]\+' /proc/stat)
cache=$XDG_RUNTIME_DIR/cpubarscache cache=$XDG_RUNTIME_DIR/cpubarscache
@ -28,23 +28,16 @@ for i in $(seq "$n_cpu"); do
delta_idle=$((new_idle - old_idle)) delta_idle=$((new_idle - old_idle))
delta_total=$((new_total - old_total)) delta_total=$((new_total - old_total))
percent=$((((delta_total - delta_idle) * 100 / delta_total) / 10)) percent=$(((delta_total - delta_idle) * 100 / delta_total))
case "$percent" in meter=$(meter_bar "$percent")
0 | 1) color="$fggreen" bar="▁" ;;
2) color="$fggreen" bar="▂" ;;
3 | 4) color="$fggreen" bar="▃" ;;
5) color="$fgorange" bar="▄" ;;
6 | 7) color="$fgorange" bar="▅" ;;
8) color="$fgred" bar="▆" ;;
*) color="$fgred" bar="▇" ;;
esac
color=$(echo "$meter" | cut -d: -f1)
if [ "$color" != "$prevcolor" ]; then if [ "$color" != "$prevcolor" ]; then
$first || printf "%b" "</span>" $first || printf "%b" "</span>"
printf "%b" "<span $color>" printf "%b" "<span $color>"
fi fi
printf "%b" "$bar" printf "%b" "$(echo "$meter" | cut -d: -f2)"
first=false first=false
prevcolor=$color prevcolor=$color

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
types=${SB_DISK_FS:-ext2,ext3,ext4,xfs,btrfs,vfat} types=${SB_DISK_FS:-ext2,ext3,ext4,xfs,btrfs,vfat}
@ -19,18 +19,11 @@ for mnt in $(findmnt -Py -t "$types"); do
$first || printf " " $first || printf " "
percent=$(df "$TARGET" | awk 'NR != 1 { gsub(/%/, "", $5); printf "%d", $5 / 10 }') percent=$(df "$TARGET" | awk 'NR != 1 { gsub(/%/, "", $5); printf "%d", $5 }')
case "$percent" in
0 | 1) color="$fggreen" bar="▁" ;;
2) color="$fggreen" bar="▂" ;;
3 | 4) color="$fggreen" bar="▃" ;;
5) color="$fggreen" bar="▄" ;;
6 | 7) color="$fggreen" bar="▅" ;;
8) color="$fgorange" bar="▆" ;;
*) color="$fgred" bar="▇" ;;
esac
printf "%b <span %b %b>%b</span>" "${icon}" "${color}" "${bggray}" "${bar}" meter=$(meter_bar "$percent")
printf "%b <span %b %b>%b</span>" "${icon}" "$(echo "$meter" | cut -d: -f1)" "${bggray}" "$(echo "$meter" | cut -d: -f2)"
first=false first=false
done done

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
# NOTE: This script takes its dwmblocks update signal as an argument so that it can refresh itself (defaults to 5) # 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 # Options can be found at https://wttr.in/:help

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
status() { status() {
nmcli --terse device status | awk -v device="$1" -F: '$1 == device { print $3 }' nmcli --terse device status | awk -v device="$1" -F: '$1 == device { print $3 }'

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
cache="${XDG_CACHE_HOME:-$HOME/.cache}/geoip" cache="${XDG_CACHE_HOME:-$HOME/.cache}/geoip"

View file

@ -1,14 +1,7 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
case "$(free -m | awk 'NR==2 { printf "%d", ($3 / $2) * 10 }')" in percent="$(free -m | awk 'NR==2 { printf "%d", ($3 / $2) * 100 }')"
0 | 1) color="$fggreen" bar="▁" ;; meter=$(meter_bar "$percent")
2) color="$fggreen" bar="▂" ;;
3 | 4) color="$fggreen" bar="▃" ;;
5) color="$fgorange" bar="▄" ;;
6 | 7) color="$fgorange" bar="▅" ;;
8) color="$fgred" bar="▆" ;;
*) color="$fgred" bar="▇" ;;
esac
printf "󰘚 <span %s %s>%s</span>" "${bggray}" "${color}" "$bar" printf "󰘚 <span %s %s>%s</span>" "$(echo "$meter" | cut -d: -f1)" "${bggray}" "$(echo "$meter" | cut -d: -f2)"

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
filter() { filter() {
if mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 3 ]; then if mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 3 ]; then

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
# TODO: Coloring based on speed # TODO: Coloring based on speed
update() { update() {

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
icon="" icon=""

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
. "colors" . libsb
pidof -x sbd-playerctl >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-playerctl" >/dev/null 2>&1 & 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" "" && exit 1 [ "$(playerctl status 2>&1)" = "No players found" ] && printf "%b" "" && exit 1