elenapan/Scripts/battery.sh
elena e43cf1ccde updated scripts, added configs, new screenshot
Former-commit-id: 80e5a611d9
Former-commit-id: d6d963dd470140b7a955399ff22fec885ddace30
2017-08-29 02:28:24 +03:00

27 lines
No EOL
736 B
Bash
Executable file

#!/bin/zsh
# upower -i $(upower -e | grep 'BAT') | grep -E "state|to\ full|percentage"
# glyphs:     
INFO="$(upower -i "$(upower -e | grep 'BAT')")"
STATE="$(echo $INFO | grep "state" | awk '{print $2}')"
# Note: I cut off the percentage sign so i can later compare POWER as an int
POWER="$(echo $INFO | grep "percentage" | awk '{print $2}' | head -c -2)"
# TODO!
if [[ "$STATE" = "discharging" ]]; then
if [ "$POWER" -ge "85" ]; then
echo "$POWER%"
elif [ "$POWER" -ge "60" ]; then
echo "$POWER%"
elif [ "$POWER" -ge "35" ]; then
echo "$POWER%"
elif [ "$POWER" -ge "10" ]; then
echo "$POWER%"
else
echo "$POWER%"
fi
else
# State = fully charged or charging
echo "$POWER%"
fi