scripts/dwm/charge.sh
2022-12-28 16:44:03 -05:00

27 lines
517 B
Bash
Executable file

#!/bin/sh
level=$(cat /sys/class/power_supply/BAT0/capacity)
stats=$(cat /sys/class/power_supply/BAT0/status)
dicon=(            )
uicon=(            )
if [ $stats == "Charging" ]; then
icon=${uicon[$(( level / 10 ))]}
else
icon=${dicon[$(( level / 10 ))]}
fi
if [ $level -ge 0 ]; then
color="^c#F75341^"
fi
if [ $level -ge 20 ]; then
color="^c#FED06E^"
fi
if [ $level -ge 50 ]; then
color="^c#98DC37^"
fi
echo "${color}${icon} ${level}%"