diff --git a/script/batinfo b/script/batinfo index 11d80a4..2b5eee8 100755 --- a/script/batinfo +++ b/script/batinfo @@ -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 diff --git a/script/tmbatinfo b/script/tmbatinfo new file mode 100755 index 0000000..c669d27 --- /dev/null +++ b/script/tmbatinfo @@ -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