File tree Expand file tree Collapse file tree 3 files changed +5
-4
lines changed Expand file tree Collapse file tree 3 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ print_battery_percentage() {
9
9
if command_exists " pmset" ; then
10
10
pmset -g batt | grep -o " [0-9]\{1,3\}%"
11
11
elif command_exists " upower" ; then
12
- local battery=$( upower -e | grep -m 1 battery)
12
+ # use DisplayDevice if available otherwise battery
13
+ local battery=$( upower -e | grep -E ' battery|DisplayDevice' | tail -n1)
13
14
if [ -z " $battery " ]; then
14
15
return
15
16
fi
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ print_battery_remain() {
43
43
if command_exists " pmset" ; then
44
44
pmset_battery_remaining_time
45
45
elif command_exists " upower" ; then
46
- battery=$( upower -e | grep -m 1 battery)
46
+ battery=$( upower -e | grep -E ' battery|DisplayDevice ' | tail -n1 )
47
47
if is_chrome; then
48
48
if battery_discharging; then
49
49
upower -i $battery | grep ' time to empty' | awk ' {printf "- %s %s left", $4, $5}'
@@ -66,7 +66,7 @@ print_battery_full() {
66
66
if command_exists " pmset" ; then
67
67
pmset_battery_remaining_time
68
68
elif command_exists " upower" ; then
69
- battery=$( upower -e | grep -m 1 battery)
69
+ battery=$( upower -e | grep -E ' battery|DisplayDevice ' | tail -n1 )
70
70
upower -i $battery | grep ' time to full' | awk ' {printf "- %s %s till full", $4, $5}'
71
71
fi
72
72
}
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ battery_status() {
32
32
pmset -g batt | awk -F ' ; *' ' NR==2 { print $2 }'
33
33
elif command_exists " upower" ; then
34
34
local battery
35
- battery=$( upower -e | grep -m 1 battery)
35
+ battery=$( upower -e | grep -E ' battery|DisplayDevice ' | tail -n1 )
36
36
upower -i $battery | awk ' /state/ {print $2}'
37
37
elif command_exists " acpi" ; then
38
38
acpi -b | awk ' {gsub(/,/, ""); print tolower($3); exit}'
You can’t perform that action at this time.
0 commit comments