You are not logged in.

#1 2023-05-11 20:30:51

jetthusher
Member
Registered: 2023-05-11
Posts: 2

Having problems with `capacity` and `energy_now` udev triggers

Hi, first time here. I'm having a problem listening to `capacity` and `energy_now` change events from udev on ThinkPad X1 (not sure if it's related).
The intention is — on every change of the `capacity` attribute of the `power_supply`, run an arbitrary script.
The problem is — they do trigger, but only once, not on change.

The udev rules are:

KERNEL=="BAT0", SUBSYSTEM=="power_supply", ACTION=="change", ATTR{capacity}=="*", ENV{POWER_SUPPLY_ENERGY_NOW}=="*", RUN+="/bin/sh -c 'echo udev rule triggered >> /var/log/udev.log'"

At some point I got desperate and started using ENV instead of the ATTR and added another RUN, just be sure that the problem is not in the script. I went through several variations of the rules including:

  • Adding/removing ACTION=="change"

  • Adding/removing KERNEL=="BAT0"

  • Having just `capacity` attr and switching it to something like "[0-9]*"

  • Adding other attributes like `status`

  • Using only ENVs, and ATTRs respectively

The attributes I'm subscribing to are present in `power_supply` and they DO work, but only once, not when the attributes change. Am I missing something here or is it the problem beyond user-space?

Thanks.

Offline

#2 2023-05-11 20:34:58

jetthusher
Member
Registered: 2023-05-11
Posts: 2

Re: Having problems with `capacity` and `energy_now` udev triggers

To clarify, every time I change the rules I do run the `udevadm control --reload && udevadm trigger`. Once I do that, I see another entry in the log file (/var/log/udev.log), but that's when it stops doing anything. The `capacity` and `energy_now` are changing and no logs are being added to the file.

Offline

Board footer

Powered by FluxBB