File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,17 @@ battery_discharging() {
10
10
}
11
11
12
12
pmset_battery_remaining_time () {
13
- pmset -g batt | grep -o ' [0-9]\{1,2\}:[0-9]\{1,2\}'
13
+ local status=" $( pmset -g batt) "
14
+ if echo $status | grep ' no estimate' > /dev/null 2>&1 ; then
15
+ echo ' - Calculating estimate...'
16
+ else
17
+ local remaining_time=" $( echo $status | grep -o ' [0-9]\{1,2\}:[0-9]\{1,2\}' ) "
18
+ if battery_discharging; then
19
+ echo $remaining_time | awk ' {printf "- %s left", $1}'
20
+ else
21
+ echo $remaining_time | awk ' {printf "- %s till full", $1}'
22
+ fi
23
+ fi
14
24
}
15
25
16
26
print_battery_remain () {
@@ -33,7 +43,9 @@ print_battery_remain() {
33
43
}
34
44
35
45
print_battery_full () {
36
- if command_exists " upower" ; then
46
+ if command_exists " pmset" ; then
47
+ pmset_battery_remaining_time
48
+ elif command_exists " upower" ; then
37
49
battery=$( upower -e | grep battery | head -1)
38
50
upower -i $battery | grep ' time to full' | awk ' {printf "- %s %s till full", $4, $5}'
39
51
fi
You can’t perform that action at this time.
0 commit comments