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?

2
  • 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, 2014 at 17:23
  • That gives me ATTR{capacity}=="79" which is the same as I get from acpi so I guess that works ... Oct 13, 2014 at 19:59

1 Answer 1

2

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

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .