mirror of
https://github.com/elenapan/dotfiles.git
synced 2025-12-27 07:44:56 +08:00
35 lines
897 B
Bash
Executable file
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
|