nixos/config/dwm/scripts/bar.sh

52 lines
1.1 KiB
Bash
Raw Normal View History

2023-08-03 18:44:13 +04:00
#!/bin/sh
2023-08-03 18:38:07 +04:00
# ^c$var^ = fg color
# ^b$var^ = bg color
interval=0
# load colors
2023-08-03 19:14:04 +04:00
. ~/.dwmscripts/themes/sako.sh
2023-08-03 18:38:07 +04:00
cpu() {
cpu_val=$(grep -o "^[^ ]*" /proc/loadavg)
2023-08-03 21:14:03 +04:00
printf "^c$black^ ^b$red^ CPU"
2023-08-03 18:38:07 +04:00
printf "^c$white^ ^b$grey^ $cpu_val"
}
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
2023-08-03 21:14:03 +04:00
up) printf "^c$black^ ^b$blue^ 󰤨 ^d^%s" " ^c$blue^Connected" ;;
down) printf "^c$black^ ^b$blue^ 󰤭 ^d^%s" " ^c$blue^Disconnected" ;;
2023-08-03 18:38:07 +04:00
esac
}
clock() {
printf "^c$black^ ^b$darkblue^ 󱑆 "
printf "^c$black^^b$blue^ $(date '+%H:%M') "
}
while true; do
2023-08-03 18:48:27 +04:00
[ $interval = 0 ] || [ $(($interval % 3600)) = 0 ]
2023-08-03 18:38:07 +04:00
interval=$((interval + 1))
2023-08-03 21:14:03 +04:00
sleep 1 && xsetroot -name "$(battery) $(brightness) $(cpu) $(mem) $(clock)"
2023-08-03 18:38:07 +04:00
done