elenapan/Scripts/battery.sh
elena dd677bde98 massive config and scripts update
Former-commit-id: 46c2bf7d26
Former-commit-id: ec0b4e689f3f8e97d837848929a1a6a9e45f779b
Former-commit-id: 19f055447f5fd666a270a51cf98b05d70716e826
2018-01-21 14:19:40 +02:00

35 lines
897 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)"
# With icons
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
# Without icons
# if [[ "$STATE" = "discharging" ]]; then
# echo "BAT* $POWER%"
# else
# # State = fully charged or charging
# echo "BAT $POWER%"
# fi