diff options
| author | Luke Smith <luke@lukesmith.xyz> | 2018-08-07 12:49:22 -0400 |
|---|---|---|
| committer | Luke Smith <luke@lukesmith.xyz> | 2018-08-07 12:49:22 -0400 |
| commit | 04a5d284a11cd51439aec2d8d43c0d1343a63ac9 (patch) | |
| tree | f852e1506efdfe87c6a5057aa7f034aa134667cf /.scripts | |
| parent | da0a7dcd22d31dfe2416ac392d0791f75f0a50c3 (diff) | |
| download | eibhear-04a5d284a11cd51439aec2d8d43c0d1343a63ac9.tar.gz eibhear-04a5d284a11cd51439aec2d8d43c0d1343a63ac9.tar.zst eibhear-04a5d284a11cd51439aec2d8d43c0d1343a63ac9.zip | |
battery module doesn't appear if no battery
Diffstat (limited to '.scripts')
| -rwxr-xr-x | .scripts/i3battery | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/.scripts/i3battery b/.scripts/i3battery index 7f89ffc..b25718d 100755 --- a/.scripts/i3battery +++ b/.scripts/i3battery @@ -1,24 +1,20 @@ #!/bin/bash -NUM=$(cat /sys/class/power_supply/BAT0/capacity) -STATE=$(cat /sys/class/power_supply/BAT0/status) -colorget() { -if [[ $NUM -ge 80 ]]; then +NUM=`cat /sys/class/power_supply/BAT0/capacity` || exit +STATUS=`cat /sys/class/power_supply/BAT0/status` + +if [ "$NUM" -ge 80 ]; then color="#00FF00" -elif [[ $NUM -ge 60 ]]; then +elif [ "$NUM" -ge 60 ]; then color="#FFFFFF" -elif [[ $NUM -ge 40 ]]; then +elif [ "$NUM" -ge 40 ]; then color="#FFF600" -elif [[ $NUM -ge 20 ]]; then +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>" +[ "$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>" |
