-
Notifications
You must be signed in to change notification settings - Fork 3
/
dwm-statusbar
executable file
·50 lines (40 loc) · 1.09 KB
/
dwm-statusbar
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
#!/bin/sh
# status bar for dwm
# color codes from dwm/config.h
color_gray="\x01" # gray on black
color_white="\x02" # white on black
print_time() {
time="$(date "+%H:%M")"
echo -ne "${color_white}${time} "
}
print_battery() {
battery_status="$(cat /sys/class/power_supply/BAT0/capacity)"
status="$(cat /sys/class/power_supply/BAT0/status)"
charging=""
if grep -q Charging <<<$status; then charging="+"; fi
battery="$battery_status"
echo -ne "${color_gray}Bat ${color_white}${charging}${battery} "
}
print_wifi() {
wifi="Off"
connection="$(iwgetid)"
if [ $? -eq 0 ]; then wifi="On"; fi
echo -ne "${color_gray}Net ${color_white}${wifi} "
}
print_mem_used() {
mem_used="$(free -m | awk 'NR==2 {print $3}')"
echo -ne "${color_gray}Mem ${color_white}${mem_used} "
}
print_temperature() {
temperature=$(cat /sys/class/thermal/thermal_zone0/temp)
temperature=$((temperature/1000))
echo -ne "${color_gray}Tem ${color_white}${temperature} "
}
while true; do
xsetroot -name "$(print_temperature)\
$(print_mem_used)\
$(print_wifi)\
$(print_battery)\
$(print_time)"
sleep 2
done