bew / dotfiles

All my dotfiles in one place!
43 stars 3 forks source link

⚠️ Add low battery warning ⚠️ #79

Closed bew closed 8 months ago

bew commented 2 years ago

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}%!"
bew commented 8 months ago

I don't use minimal WM anymore at the moment, and KDE has good warning