nixos/config/dwmbar/bar.sh

72 lines
1.7 KiB
Bash
Raw Normal View History

2023-09-11 08:05:16 +04:00
#!/bin/sh
# ^c$var^ = fg color
# ^b$var^ = bg color
interval=0
# load colors
. ~/.dwmscripts/themes/sako.sh
cpu() {
cpu_val=$(grep -o "^[^ ]*" /proc/loadavg)
2023-09-11 14:03:43 +04:00
printf "^c$white^ ^b$red^ CPU"
printf "^c$white^ ^b$lightred^ $cpu_val"
2023-09-11 08:05:16 +04:00
}
battery() {
2023-09-11 17:06:03 +04:00
get_capacity="$(cat /sys/class/power_supply/BAT*/capacity)"
get_status="$(cat /sys/class/power_supply/BAT*/status)"
2023-09-11 08:05:16 +04:00
case "$get_status" in
Charging) printf "^c$blue^ 󰂄 $get_capacity" ;;
Discharging) if (( $get_capacity <= 20)); then
2023-09-11 17:06:03 +04:00
printf "^c$white^ ^b$lightred^ 󰂃"
printf "^c$white^ ^b$black^ $get_capacity"
2023-09-11 08:05:16 +04:00
else
2023-09-11 14:03:43 +04:00
printf "^c$white^ ^b$blue 󰁹"
printf "^c$white^ ^b$black^ $get_capacity"
2023-09-11 08:05:16 +04:00
fi ;;
esac
}
audio() {
get_vol=$(pamixer --get-volume-human)
if [ $get_vol = 'muted' ]; then
printf "^c$blue^ 󰕾 Muted"
else
printf "^c$blue^ 󰕾 $get_vol"
fi
#printf "^c$blue^ 󰕾 $get_vol"
}
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 ]
interval=$((interval + 1))
sleep 1 && xsetroot -name "$(audio) $(battery) $(brightness) $(cpu) $(mem) $(clock)"
done