You are not logged in.

#1 2015-03-01 23:51:49

dmitriy
Member
Registered: 2013-12-17
Posts: 5

Udev battery capacity change rule doesn't trigger

Greetings!

Per this topic and this wiki section I tried to make my laptop suspend on reaching low battery level, but couldn't make it work.
I use i3wm and powerdown and no other power management packages.
My guess is that udev doesn't get a battery capacity change event as in `udevadm monitor` there are no changes over time while battery is discharging (however, there are when charger is plugged in and out)

Right now, /etc/udev/rules.d/99-lowbat.rules is as follows:

SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-4]", RUN+="/usr/bin/systemctl suspend"
SUBSYSTEM=="power_supply", ATTR{capacity}=="[70-90]", RUN+="/usr/bin/touch /tmp/eventcapacity7090"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[70-90]", RUN+="/usr/bin/systemctl suspend"

So, am I right or not and how can I make my laptop respond to changes in battery level?

Thanks

Last edited by dmitriy (2015-03-01 23:52:50)

Offline

#2 2015-03-02 00:22:12

\hbar
Member
Registered: 2014-03-15
Posts: 165

Re: Udev battery capacity change rule doesn't trigger

You could use incron to look at /sys/class/power_supply/BAT*/capacity . From what I've been reading this may or may not work, but it's worth a try.

Offline

#3 2015-03-02 00:26:55

dmitriy
Member
Registered: 2013-12-17
Posts: 5

Re: Udev battery capacity change rule doesn't trigger

As far as I understand, it isn't related to udev anymore and is more of like usual cron which just watches filesystem, am I right?

Offline

#4 2015-03-02 09:16:48

\hbar
Member
Registered: 2014-03-15
Posts: 165

Re: Udev battery capacity change rule doesn't trigger

Right, it's not related to udev, but since your kernel doesn't seem to be sending uevents when your battery capacity changes, perhaps udev isn't the way to go.

Offline

#5 2015-03-02 15:28:10

dmitriy
Member
Registered: 2013-12-17
Posts: 5

Re: Udev battery capacity change rule doesn't trigger

I hoped there could be a way to make it send them, but I understand I should use the other thing.
By the way, is acpid an option or it depends the same way on kernel events?

Last edited by dmitriy (2015-03-02 15:28:33)

Offline

#6 2015-04-17 16:38:28

juego
Member
Registered: 2015-04-13
Posts: 41
Website

Re: Udev battery capacity change rule doesn't trigger

I'd like to jump in in the conversation, because I have the exact same problem.
I'm also looking at acpid but can't figure out what type of config I have to set up to make it work.
Should I use systemd services to watch "acpi -b" or else.

Thank you

Offline

Board footer

Powered by FluxBB