~alexdavid/dotfiles

dotfiles/i3blocks/battery.sh -rwxr-xr-x 826 bytes
73a15050 — Alex David Update vifminfo ignore path 30 days ago
                                                                                
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
27
28
29
30
31
#!/usr/bin/env bash

which acpi &> /dev/null || exit 0

PERCENT=$(acpi -b | sed -E 's/.+, ([0-9]+)%.*/\1/')
STATUS=$(acpi -b | sed -E 's/.+: (\w+),.+/\1/')

COLOR=""
if [ "$PERCENT" -lt 5 ]; then
  [ "$STATUS" != Charging ] && notify-send "  Low Battery!" "$PERCENT% Battery remaining"
  COLOR="#FF0000"
fi

if [ "$STATUS" = Charging ]; then ICON=""
elif [ "$PERCENT" -lt 10 ]; then ICON=""
elif [ "$PERCENT" -lt 20 ]; then ICON=""
elif [ "$PERCENT" -lt 30 ]; then ICON=""
elif [ "$PERCENT" -lt 40 ]; then ICON=""
elif [ "$PERCENT" -lt 50 ]; then ICON=""
elif [ "$PERCENT" -lt 60 ]; then ICON=""
elif [ "$PERCENT" -lt 70 ]; then ICON=""
elif [ "$PERCENT" -lt 80 ]; then ICON=""
elif [ "$PERCENT" -lt 90 ]; then ICON=""
else ICON=""
fi

printf "​"

echo "$ICON"
echo "$ICON"
echo "$COLOR"