blob: ae594160544cc7fc8356426b779d5f07c36c17c5 (
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
|
#!/bin/sh
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 "$status$capacity%"
done
|