1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-03-18 18:07:45 +01:00

61 lines
1.1 KiB
Plaintext
Raw Normal View History

2023-10-22 00:05:00 +02:00
#!/bin/sh
2020-04-02 00:06:34 +02:00
2023-10-22 00:05:00 +02:00
acpi=$(acpi -b)
2019-09-07 17:42:18 +02:00
2023-10-22 00:19:06 +02:00
if [ "$acpi" = "" ]; then
2023-10-22 00:05:00 +02:00
echo ""
return
fi
total=$(echo $acpi | sed 's/.*:\ //')
status="$(echo $total | cut -d',' -f1)"
capacity="$(echo $total | cut -d',' -f2 | sed 's/%//')"
2023-10-22 00:35:00 +02:00
if [ "$status" = "Discharging" ] && [ $capacity -le 20 ] ; then
notify-send -u critical "Battery" "Low capacity: $capacity%"
2023-10-22 00:35:00 +02:00
fi
2023-10-22 00:05:00 +02:00
if [ $capacity -gt 40 ]
then
color="^b#282828^^c#dfdfdf^"
elif [ $capacity -gt 20 ]
then
color="^b#282828^^c#ffff00^"
else
color="^b#282828^^c#ff0000^"
fi
2023-10-22 00:05:00 +02:00
case "$status" in
"Discharging")
if [ $capacity -gt 75 ]
then
icon=""
elif [ $capacity -gt 60 ]
then
icon=""
elif [ $capacity -gt 40 ]
then
icon=""
elif [ $capacity -gt 20 ]
then
icon=""
else
icon=""
fi
;;
2023-10-22 00:05:00 +02:00
"Not charging")
icon="";;
2023-10-22 00:05:00 +02:00
"Charging")
icon="";;
2023-10-22 00:05:00 +02:00
"Unknown")
icon="";;
2023-10-22 00:05:00 +02:00
"Full")
icon="⚡";;
2023-10-22 00:05:00 +02:00
esac
2023-10-22 00:35:00 +02:00
capacity=$(echo "$capacity" | sed -e 's/$//')
capacity=$(printf %3s $capacity | tr ' ' ' ')
echo "$color $icon ^d^"