2018-07-16 23:16:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-08-07 16:49:22 +00:00
|
|
|
NUM=`cat /sys/class/power_supply/BAT0/capacity` || exit
|
|
|
|
STATUS=`cat /sys/class/power_supply/BAT0/status`
|
|
|
|
|
|
|
|
if [ "$NUM" -ge 80 ]; then
|
2018-07-16 23:16:47 +00:00
|
|
|
color="#00FF00"
|
2018-08-07 16:49:22 +00:00
|
|
|
elif [ "$NUM" -ge 60 ]; then
|
2018-07-17 18:45:12 +00:00
|
|
|
color="#FFFFFF"
|
2018-08-07 16:49:22 +00:00
|
|
|
elif [ "$NUM" -ge 40 ]; then
|
2018-07-16 23:16:47 +00:00
|
|
|
color="#FFF600"
|
2018-08-07 16:49:22 +00:00
|
|
|
elif [ "$NUM" -ge 20 ]; then
|
2018-07-16 23:16:47 +00:00
|
|
|
color="#FFAE00"
|
|
|
|
else
|
|
|
|
color="#FF0000"
|
|
|
|
fi
|
|
|
|
|
2018-08-07 16:49:22 +00:00
|
|
|
[ "$STATUS" = "Charging" ] && color="#FFF"
|
|
|
|
|
|
|
|
echo "<span color='$color'>`sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/❓/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g" <<<"$STATUS"` `sed -e 's/$/%/' <<<"$NUM"`</span>"
|