dotfiles/.scripts/battery.sh

32 lines
697 B
Bash
Raw Normal View History

#!/usr/bin/env bash
status=$(acpi | awk '{orint $3;}' | sed 's/,//g')
2016-12-16 21:06:16 +00:00
capacity=$(acpi | awk '{print $4;}' | sed 's/%//g' | sed 's/,//g')
color=true
sparks=$(spark 0 $capacity 100)
2016-12-11 23:43:09 +00:00
echo -n "%{F#e5c078}"
if [[ $status == "Charging" ]]; then
echo -en "\uf0e7"
elif [[ $capacity -ge "85" ]]; then
echo -en "\uf240"
elif [[ $capacity -ge "65" ]]; then
echo -en "\uf241"
elif [[ $capacity -ge "45" ]]; then
echo -en "\uf242"
elif [[ $capacity -ge "15" ]]; then
echo -en "\uf243"
elif [[ $capacity -ge "0" ]]; then
color=true
echo -en "%{F#cc6666}\uf244"
fi
echo -n "%{F-}"
echo -n "Bat: $capacity% [${sparks:1:1}]"
2016-12-11 23:43:09 +00:00
if [[ color ]]; then
echo "%{F-}"
else
echo
fi