diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2022-10-03 21:42:20 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2022-10-03 21:42:20 +0530 |
commit | af120ab348f2e1a5a39dec035ed9dcf84189a64e (patch) | |
tree | 2a3aadd7ce1b7b771dfe3fe7c983569726c8d7ed /scripts/bar.sh | |
download | dotfiles-af120ab348f2e1a5a39dec035ed9dcf84189a64e.tar.gz dotfiles-af120ab348f2e1a5a39dec035ed9dcf84189a64e.tar.bz2 dotfiles-af120ab348f2e1a5a39dec035ed9dcf84189a64e.zip |
dotfiles
Diffstat (limited to 'scripts/bar.sh')
-rwxr-xr-x | scripts/bar.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/scripts/bar.sh b/scripts/bar.sh new file mode 100755 index 0000000..4a90e4d --- /dev/null +++ b/scripts/bar.sh @@ -0,0 +1,63 @@ +#!/bin/dash + +# ^c$var^ = fg color +# ^b$var^ = bg color + +interval=0 + +# load colors +. ~/.config/chadwm/scripts/bar_themes/nord + +cpu() { + cpu_val=$(grep -o "^[^ ]*" /proc/loadavg) + + printf "^c$black^ ^b$green^ CPU" + printf "^c$white^ ^b$grey^ $cpu_val" +} + +pkg_updates() { + updates=$(doas xbps-install -un | wc -l) # void + # updates=$(checkupdates | wc -l) # arch , needs pacman contrib + # updates=$(aptitude search '~U' | wc -l) # apt (ubuntu,debian etc) + + if [ -z "$updates" ]; then + printf "^c$green^ Fully Updated" + else + printf "^c$green^ $updates"" updates" + fi +} + +battery() { + get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)" + printf "^c$blue^ $get_capacity" +} + +brightness() { + printf "^c$red^ " + printf "^c$red^%.0f\n" $(cat /sys/class/backlight/*/brightness) +} + +mem() { + printf "^c$blue^^b$black^ " + printf "^c$blue^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)" +} + +wlan() { + case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in + up) printf "^c$black^ ^b$blue^ ^d^%s" " ^c$blue^Connected" ;; + down) printf "^c$black^ ^b$blue^ ^d^%s" " ^c$blue^Disconnected" ;; + esac +} + +clock() { + printf "^c$black^ ^b$darkblue^ " + printf "^c$black^^b$blue^ $(date '+%H:%M') " +} + +while true; do + + [ $interval = 0 ] || [ $(($interval % 3600)) = 0 ] && updates=$(pkg_updates) + interval=$((interval + 1)) + + sleep 1 && xsetroot -name "$updates $(battery) $(brightness) $(cpu) $(mem) $(wlan) $(clock)" +done |