separate battery script with colors

This commit is contained in:
Luke Smith 2018-07-16 19:16:47 -04:00
parent df6363a298
commit c0a2cce420
2 changed files with 26 additions and 4 deletions

View file

@ -47,11 +47,11 @@ interval=10
[wifi] [wifi]
label=📶 label=📶
#instance=wlp3s0 instance=wlp2s0
interval=10 interval=10
[battery] [battery]
command=echo $(cat /sys/class/power_supply/BAT0/status | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/❓/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g") $(cat /sys/class/power_supply/BAT0/capacity | sed -e 's/$/%/') command=i3battery
interval=5 interval=5
[time] [time]

View file

@ -1,2 +1,24 @@
#!/bin/sh #!/bin/bash
#acpi | cut -d " " -f3-5 | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g" NUM=$(cat /sys/class/power_supply/BAT0/capacity)
STATE=$(cat /sys/class/power_supply/BAT0/status)
colorget() {
if [[ $NUM -ge 80 ]]; then
color="#00FF00"
elif [[ $NUM -ge 60 ]]; then
color="#FF0000"
elif [[ $NUM -ge 40 ]]; then
color="#FFF600"
elif [[ $NUM -ge 20 ]]; then
color="#FFAE00"
else
color="#FF0000"
fi ;}
if [[ $STATE == "Charging" ]]; then
color="#ffffff"
else
colorget
fi
echo "<span color='$color'>$(echo $STATE | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/❓/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g") $(echo $NUM | sed -e 's/$/%/')</span>"