all repos — dotfiles @ 08f1f7e105600d2f2249f3393ad3edb5e457b9f0

linux dotfiles

config/i3blocks/battery (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
#!/bin/sh
percent=$(acpi | cut -d ' ' -f4 | tail -1 |  tr -d ',')
state=$(acpi | cut -d ' ' -f3 | tail -1 | tr -d ',')
percent_no=$(echo -n $percent | tr -d '%')

case $state in
    Charging)
        symbol="<span font='Font Awesome 5 Free 9'>\uf0e7 </span>"
        ;;
    *)
        #symbol="<span font='Icons 11'>\uf213</span>"
        #symbol="<span font='Material Design Icons'>\uf079</span>"
        [ $percent_no -le 40 ] && notify-send -i battery-low -u critical "Battery Low"
        ;;
esac

echo -e "$symbol$percent"

awk -v percent=$percent_no '
    BEGIN {
        if (percent <= 30) {
            print "#FF0000";
            exit 33;
        }
    }
'