blob: 275ef28f43a5451616cf422c33c8de79d1c41c17 (
plain)
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
|
#!/usr/bin/env bash
# Display the current battery status.
# requires joypixels font in dwm config.def.h
# This is updated by signal 2, so 2 + 34 =
# kill -36 $(pidof dwmblocks) or
# pkill -RTMIN+2 dwmblocks
# Loop through all attached batteries.
for battery in /sys/class/power_supply/BAT?*; do
# If non-first battery, print a space separator.
[ -n "${capacity+x}" ] && printf " "
capacity="$(cat "$battery/capacity" 2>&1)"
if [ "$capacity" -gt 90 ]; then
status="â
"
elif [ "$capacity" -gt 60 ]; then
status="đ "
elif [ "$capacity" -gt 40 ]; then
status="đĒĢ "
elif [ "$capacity" -gt 10 ]; then
status="â ī¸ "
else
status="â "
fi
case "$(cat "$battery/status" 2>&1)" in
"Full")
status="âĄ"
;;
"Discharging")
if [ "$capacity" -le 20 ]; then
status="īĒ$status"
fi
;;
"Charging")
status="đ$status"
;;
"Not charging")
status="âģī¸"
;;
"Unknown")
status="? $status"
;;
*)
exit 1
;;
esac
echo -e " $status $capacity% â"
done
|