blob: 51464a5ea2711185ea3153fa6aad3e92a89539da (
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
|
#!/bin/sh
names="sbs-20-000b BAT0 BAT1"
dir=""
for n in $names; do
if [ -d "/sys/class/power_supply/$n" ] ; then
dir=$n
break
fi;
done
fetch() {
cat /sys/class/power_supply/$dir/$1
}
status=$(fetch status)
if [ "$status" = "Full" ] ; then
echo $status
else
if [ "$status" = "Discharging" ]; then
time=$(fetch time_to_empty_avg)
else
time=$(fetch time_to_full_avg)
fi;
hours=$(($time/3600))
minutes=$(($time/60-$hours*60))
echo $status $(fetch capacity)%, "$hours"h "$minutes"m
fi;
|