2

I'm using Debian Jessie with systemd. In the past I've used an acpid script that let's my computer hibernate when the battery is 5% or below.

In an attempt to make a replacement for that I've made this udev rule (as the described here in the Arch wiki):

$ cat /etc/udev/rules.d/99-lowbat.rules 
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="5", RUN+="/usr/bin/systemctl hibernate" 
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="4", RUN+="/usr/bin/systemctl hibernate"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="3", RUN+="/usr/bin/systemctl hibernate"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="2", RUN+="/usr/bin/systemctl hibernate"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="1", RUN+="/usr/bin/systemctl hibernate"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="0", RUN+="/usr/bin/systemctl hibernate"

It's not working.

I've tried making this test rule which works:

$ cat /etc/udev/rules.d/98-discharging.rules
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", RUN+="/usr/bin/touch /home/myname/discharging"

Why doesn't the first rule work to hibernate my laptop?

  • udevadm monitor should let you know if the battery sends events when the charge level changes. udevadm info -q property -a --path /sys/class/power_supply/BAT_0 (or whatever the actual path to the battery is) will let you know if udev has a capacity attribute for it. Those may need to be run as root (or via sudo). – derobert Oct 13 '14 at 17:23
  • That gives me ATTR{capacity}=="79" which is the same as I get from acpi so I guess that works ... – MajorBriggs Oct 13 '14 at 19:59
2

The path you used for systemctl is wrong. systemctl is in /bin/, not /usr/bin/ (this is Debian/Ubuntu specific).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.