zsh: prompt: fix battery display on computers without acpi
This commit is contained in:
parent
2e24e3e44a
commit
67a67f7988
1 changed files with 10 additions and 10 deletions
|
|
@ -59,17 +59,17 @@ zshrc_prompt_precmd() {
|
||||||
local battery_pct=
|
local battery_pct=
|
||||||
if type acpi &> /dev/null ; then
|
if type acpi &> /dev/null ; then
|
||||||
battery_pct="$(acpi -b | cut -d, -f2 | sed -e 's/[^0-9]//g')"
|
battery_pct="$(acpi -b | cut -d, -f2 | sed -e 's/[^0-9]//g')"
|
||||||
fi
|
|
||||||
|
|
||||||
# colorize battery percentage or display status
|
# colorize battery percentage or display status
|
||||||
if [[ $(acpi -a | cut -d':' -f2) == " on-line" ]]; then
|
if [[ $(acpi -a | cut -d':' -f2) == " on-line" ]]; then
|
||||||
battery_pct="charging"
|
battery_pct="charging"
|
||||||
elif [[ $battery_pct -le 20 ]]; then
|
elif [[ $battery_pct -le 20 ]]; then
|
||||||
battery_pct="%F{red}${battery_pct}%%%f"
|
battery_pct="%F{red}${battery_pct}%%%f"
|
||||||
elif [[ $battery_pct -le 65 ]]; then
|
elif [[ $battery_pct -le 65 ]]; then
|
||||||
battery_pct="%F{yellow}${battery_pct}%%%f"
|
battery_pct="%F{yellow}${battery_pct}%%%f"
|
||||||
else
|
else
|
||||||
battery_pct="%F{green}${battery_pct}%%%f"
|
battery_pct="%F{green}${battery_pct}%%%f"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# prefix characters in first and second line
|
# prefix characters in first and second line
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue