Suspend on low battery

on under Snippets

I had some problems with the power connector on my new laptop, it was unreliable and the slightest movement sometimes caused it to lose connection. With no LEDs for either battery state or external power — gotta love those new Thinkpads — sudden shut offs were no rarity.

So, I used this nifty udev rule to automatically suspend my laptop if the battery charge drops below 16%:

SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-9]|1[0-5]", RUN+="/usr/bin/systemctl suspend"

Note: It lives in /etc/udev/rules.d/99-lowbat.rules

udev, linux