blob: 33e6a743e22c8b8bda566bfe952925debc8663ca (
plain) (
blame)
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
|
#!/bin/sh
base="/sys/class/power_supply/BAT0/"
low=25
med=50
high=75
icon_charging_high=
icon_charging_low=
icon_charging_med=
icon_charging_dry=
icon_high=
icon_low=
icon_med=
icon_dry=
full=$(< $base/energy_full_design)
now=$(< $base/energy_now)
stat=$(< $base/status)
percent=$(echo "result = $now / $full * 100; scale=0; result / 1" | bc -l)
if [ "$stat" = "Discharging" ]; then
[ $percent -lt $low ] && printf $icon_dry
[ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_low
[ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_med
[ $percent -ge $high ] && printf $icon_high
else
[ $percent -lt $low ] && printf $icon_charging_dry
[ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_charging_low
[ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_charging_med
[ $percent -ge $high ] && printf $icon_charging_high
fi
printf " %s%%\n" $percent
|