2019-10-21 18:53:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-10-21 19:09:02 +00:00
|
|
|
# Prints out battery percentage
|
|
|
|
|
2019-10-25 15:31:27 +00:00
|
|
|
CHARGING_ICON=''
|
|
|
|
WARNING_ICON=''
|
|
|
|
BATTERY_FULL_ICON=''
|
|
|
|
BATTERY_2_ICON=''
|
|
|
|
BATTERY_3_ICON=''
|
|
|
|
BATTERY_4_ICON=''
|
2019-10-21 19:09:02 +00:00
|
|
|
|
2019-10-25 00:24:02 +00:00
|
|
|
FULL_AT=98
|
|
|
|
|
|
|
|
BAT_ICON=""
|
|
|
|
ICON=""
|
|
|
|
|
2019-10-21 18:53:57 +00:00
|
|
|
get_battery()
|
|
|
|
{
|
2019-10-25 00:24:02 +00:00
|
|
|
# The vast majority of people only use one battery.
|
|
|
|
|
|
|
|
if [ -d /sys/class/power_supply/BAT0 ]; then
|
|
|
|
capacity=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
|
|
charging=$(cat /sys/class/power_supply/BAT0/status)
|
|
|
|
if [[ "$charging" == "Charging" ]]; then
|
|
|
|
ICON="$CHARGING_ICON"
|
|
|
|
elif [[ $capacity -le 25 ]]; then
|
|
|
|
ICON="$WARNING_ICON"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $capacity -ge $FULL_AT ]]; then
|
|
|
|
BAT_ICON=$BATTERY_FULL_ICON
|
|
|
|
elif [[ $capacity -le 25 ]]; then
|
|
|
|
BAT_ICON=$BATTERY_4_ICON
|
|
|
|
elif [[ $capacity -le 50 ]]; then
|
|
|
|
BAT_ICON=$BATTERY_3_ICON
|
|
|
|
elif [[ $capacity -le $FULL_AT ]]; then
|
|
|
|
BAT_ICON=$BATTERY_2_ICON
|
|
|
|
fi
|
|
|
|
fi
|
2019-10-25 00:27:35 +00:00
|
|
|
echo "$ICON $BAT_ICON $capacity%"
|
2019-10-21 18:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_battery
|