blob: 346a5836a72988c5043d0ee052b70f182afc3eab (
plain) (
blame)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/bin/dash
# ^c$var^ = fg color
# ^b$var^ = bg color
interval=0
# run bar script and dwm ( do not remove this )
SYMLINKDIR=$(readlink -f "$0")
BASEDIR=$(dirname "$SYMLINKDIR")
# load colors!
. $BASEDIR/themes/dracula
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() {
capacity_path="/sys/class/power_supply/BAT0/capacity"
status_path="/sys/class/power_supply/BAT0/status"
if [ -f "${capacity_path}" ]
then
get_capacity="$(cat /sys/class/power_supply/BAT0/capacity)"
fi
if [ -f "${status_path}" ]
then
get_status="$(cat /sys/class/power_supply/BAT0/status)"
fi
case "$get_status" in
Discharging)
printf "^c$blue^ 🔋 $get_capacity"
;;
*)
printf "^c$blue^ $get_capacity"
;;
esac
}
brightness() {
brightness_path=/sys/class/backlight/*/brightness
brightness_max_path=/sys/class/backlight/*/max_brightness
if [ -f "${brightness_path}" ]
then
brightness="$(cat $brightness_path)"
fi
if [ -f "${brightness_max_path}" ]
then
brightness_max="$(cat /sys/class/backlight/*/max_brightness)"
fi
level=$(echo "scale=2; $brightness / $brightness_max * 100" | bc)
printf "^c$red^ "
printf "^c$red^%.0f\n" $level
}
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/w*/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') "
}
volume() {
pactl_output="$(pactl list sinks )"
is_mute="$(echo "$pactl_output" | grep Mute | grep -oE "yes|no")"
if [ "$is_mute" = "yes" ]
then
printf "^c$red^ 🔇 mute"
else
volume_status="$(echo "$pactl_output" | grep olume | grep -oE "\w+%" | head -n 1)"
printf "^c$yellow^ 🔊 %s" $volume_status
fi
}
keyboard() {
keyboard_bits=$(xset -q | grep -A 0 'LED' | cut -c59-67)
case "$keyboard_bits" in
00000000)
printf "^c$red^ ⌨️ en"
;;
00001000)
printf "^c$red^ ⌨️ no"
;;
*)
printf "^c$red^ ⌨️ $keyboard_bits"
;;
esac
}
while true; do
#[ $interval = 0 ] || [ $(($interval % 3600)) = 0 ] && updates=$(pkg_updates)
interval=$((interval + 1))
sleep 1 && xsetroot -name "$updates $(battery) $(brightness) $(cpu) $(mem) $(wlan) $(volume) $(clock)"
done
|