-
Notifications
You must be signed in to change notification settings - Fork 0
/
bar.sh
59 lines (46 loc) · 1.42 KB
/
bar.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/dash
# ^c$var^ = fg color
# ^b$var^ = bg color
interval=0
# load colors
. ~/.config/chadwm/scripts/bar_themes/onedark
cpu() {
cpu_val=$(grep -o "^[^ ]*" /proc/loadavg)
printf "^c$black^ ^b$green^ CPU"
printf "^c$white^ ^b$grey^ $cpu_val"
}
pkg_updates() {
#updates=$({ timeout 20 doas xbps-install -un 2>/dev/null || true; } | wc -l) # void
updates=$({ timeout 20 checkupdates 2>/dev/null || true; } | wc -l) # arch
# updates=$({ timeout 20 aptitude search '~U' 2>/dev/null || true; } | 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/wlp0*/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 '+%I:%M %p') "
}
while true; do
sleep 1 && xsetroot -name "$(brightness) $(cpu) $(mem) $(wlan) $(clock)"
done