blob: 61d02f7bcdf8a3bf6fce2301c0023e9cac96b847 (
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
61
62
63
64
65
66
67
68
|
#!/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
bat="BAT0"
battery="/sys/class/power_supply/$bat"
capacity="$(cat "$battery/capacity" 2>&1)"
if [ "$capacity" -gt 95 ]; then
status=""
elif [ "$capacity" -gt 90 ]; then
status=""
elif [ "$capacity" -gt 80 ]; then
status=""
elif [ "$capacity" -gt 70 ]; then
status=""
elif [ "$capacity" -gt 60 ]; then
status=""
elif [ "$capacity" -gt 50 ]; then
status=""
elif [ "$capacity" -gt 40 ]; then
status=""
elif [ "$capacity" -gt 30 ]; then
status=""
elif [ "$capacity" -gt 20 ]; then
status=""
elif [ "$capacity" -gt 10 ]; then
status=""
else
status=""
fi
case "$(cat "$battery/status" 2>&1)" in
"Full")
status="⚡$status"
;;
"Discharging")
#[ "$rrtn" -eq "$rrtn" ] && remaining="$(date -u -d @$((rrtn * 60)) +'%-Hh%-Mm')"
rrtn="$(cat /sys/devices/platform/smapi/$bat/remaining_running_time_now)"
[ "$rrtn" -eq "$rrtn" ] && remaining="$((rrtn/60))h$((rrtn%60))"
status="$remaining $status"
;;
"Charging")
status=" $status"
;;
"Not charging")
status=" status"
;;
"Unknown")
status="? $status"
;;
*)
exit 1
;;
esac
echo -e " $status $capacity% \uE0b1"
|