tmuxrc: improve battery indication

This commit is contained in:
Rob Watson 2023-06-08 23:19:01 +02:00
parent 93bcfe9f9c
commit adcab9d77f
2 changed files with 16 additions and 1 deletions

View File

@ -7,5 +7,5 @@ set -e
if [ $(uname -s) = "Darwin" ]; then
echo "" # TODO
else # Linux
echo "$(cat /sys/class/power_supply/BAT0/capacity)%"
echo "$(cat /sys/class/power_supply/BAT0/capacity)"
fi

15
script/tmbatinfo Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
#
# Print battery percentage to stdout
set -e
pc=$(batinfo)
if [ "$pc" -gt 40 ]; then
echo "#[fg=black, bg=green] $(batinfo)% #[default]"
elif [ "$pc" -gt 10 ]; then
echo "#[fg=black, bg=yellow] $(batinfo)% #[default]"
else
echo "#[fg=black, bg=red] $(batinfo)% #[default]"
fi