⚠️ Add low battery warning ⚠️
bew opened this issue · comments
Benoit de Chezelles commented
From: https://niekvanleeuwen.nl/2020/04/making-arch-linux-i3-wm-usable/#battery-notifications
# for a udev rule file
# Send notification when battery is low
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[15-6]", RUN+="/path/to/battery-warning.sh"
# Suspend the system when battery level drops to 5% or lower
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="/usr/bin/systemctl suspend"
And the script battery-warning.sh
could be sth like;
#!/bin/sh
battery_level=`acpi -b | cut -d ' ' -f 4 | grep -o '[0-9]*' | head -1`
notify-send "Battery low" "Battery level is ${battery_level}%!"