nixos/config/dwm/scripts/bar.sh

71 lines
1.6 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-05 23:55:27 +04:00
printf "^c$white^ ^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)"
2023-08-04 00:06:14 +04:00
get_status="$(cat /sys/class/power_supply/BAT1/status)"
2023-08-04 18:05:14 +04:00
case "$get_status" in
2023-08-04 23:18:33 +04:00
Charging) printf "^c$blue^ 󰂄 $get_capacity" ;;
2023-08-04 19:08:05 +04:00
Discharging) if (( $get_capacity <= 20)); then
2023-08-04 23:18:33 +04:00
printf "^c$lightred^ 󰂃 $get_capacity"
2023-08-04 19:08:05 +04:00
else
2023-08-07 18:10:26 +04:00
printf "^c$white^ 󰁹 $get_capacity"
2023-08-04 19:08:05 +04:00
fi ;;
2023-08-04 18:05:14 +04:00
esac
#printf "^c$blue^  $get_capacity"
2023-08-03 18:38:07 +04:00
}
2023-08-04 23:22:54 +04:00
audio() {
2023-08-04 23:28:26 +04:00
get_vol=$(pamixer --get-volume-human)
2023-08-05 00:11:33 +04:00
if [ $get_vol = 'muted' ]; then
2023-08-05 23:55:27 +04:00
printf "^c$white^  Muted"
2023-08-05 00:11:33 +04:00
else
2023-08-07 18:10:26 +04:00
printf "^c$white^  $get_vol"
2023-08-05 00:11:33 +04:00
fi
#printf "^c$blue^ 󰕾 $get_vol"
2023-08-04 23:22:54 +04:00
}
2023-08-03 18:38:07 +04:00
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-04 23:22:54 +04:00
sleep 1 && xsetroot -name "$(audio) $(battery) $(brightness) $(cpu) $(mem) $(clock)"
2023-08-03 18:38:07 +04:00
done