mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 15:53:22 +01:00
Report only active battery (#4726)
On a system with multiple batteries (like thinkpads) report percentage and time remaining only for the active battery (the one being discharged). Ideally we should report all batteries, but acpi only shows time remaining for the active battery. Also callers of these functions expect a single return value. This is still better than reporting 596% remaining (like it did on my laptop). For the reference, the output of acpi command with multiple batteries looks like this: Battery 0: Unknown, 5% Battery 1: Discharging, 86%, 03:14:04 remaining
This commit is contained in:
parent
5f6f7b6e8d
commit
b8b8762915
@ -117,7 +117,7 @@ elif [[ "$OSTYPE" = linux* ]]; then
|
|||||||
|
|
||||||
function battery_pct() {
|
function battery_pct() {
|
||||||
if (( $+commands[acpi] )); then
|
if (( $+commands[acpi] )); then
|
||||||
acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]'
|
acpi 2>/dev/null | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user