blob: 3f3dea7eaceed12a64561143179aefb647042e90 (
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
59
60
|
#!/bin/sh
# Display the current battery status.
# requires joypixels font in dwm config.def.h
notify() {
dunstify \
-i battery-good-symbolic \
-t 10000 \
-h string:x-canonical-private-synchronous:battery \
"Battery" "$1"
}
case "$BLOCK_BUTTON" in
# ugly must do better
1)
INF=$(inxi -B --extra 3 -c 0 -y 1)
REM=$(acpi | cut -d , -f 3)
DAT=$(echo "$INF$REM" | sed -e 's/^[ \t]*//')
notify "$DAT"
;;
3)
notify "$(acpi -b | awk -F ': |, ' '{printf "%s\n%s\n", $2, $4}')"
;;
esac
# 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"
color=1
fi
;;
Charging) status="đ$status" ;;
"Not charging") status="âģī¸" ;;
Unknown) status="? $status" ;;
*) exit 1 ;;
esac
echo "â $status $capacity%"
done
|