Skip to content

Commit cc18fae

Browse files
mas90martinbeentjes
authored andcommitted
If upower reports a percentage, just use that (#76)
I have a device (Gemini PDA) whose energy and energy-full are both zero, but the percentage is correct so just use that. Upower probably knows best. Probably also fixes #65.
1 parent c60c41c commit cc18fae

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/battery_percentage.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ print_battery_percentage() {
1414
if [ -z "$battery" ]; then
1515
return
1616
fi
17+
local percentage=$(upower -i $battery | awk '/percentage:/ {print $2}')
18+
if [ "$percentage" ]; then
19+
echo $percentage
20+
return
21+
fi
1722
local energy
1823
local energy_full
1924
energy=$(upower -i $battery | awk -v nrg="$energy" '/energy:/ {print nrg+$2}')

0 commit comments

Comments
 (0)