You are not logged in.

#1 2020-03-27 18:52:08

Ulilop
Member
From: CDMX, México
Registered: 2020-03-27
Posts: 5

Udev power_supply rule not working with tlp

Hi everyone,

I'ven trying to setup some rules with udev:

ls /etc/udev/rules.d/ >
97-charging.rules  98-discharging.rules  99-lowbat.rules

97-charging.rules >
SUBSYSTEM=="power_supply", ATTR{status}=="Charging", RUN+="/usr/bin/nbfc set -s 100"

98-discharging.rules >
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", RUN+="/usr/bin/nbfc set -a"

99-lowbat.rules >
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-10]", RUN+="/usr/bin/systemctl hibernate"

The events are visible, and I can even test the udev rule:

devadm info --attribute-walk --path=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0 >
  looking at device '/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0':
    KERNEL=="BAT0"
    SUBSYSTEM=="power_supply"
    DRIVER==""
    ATTR{charge_now}=="3264000"
    ATTR{present}=="1"
    ATTR{technology}=="Li-ion"
    ATTR{alarm}=="0"
    ATTR{charge_full_design}=="3296000"
    ATTR{serial_number}==" "
    ATTR{status}=="Discharging"
    ATTR{voltage_min_design}=="10800000"
    ATTR{voltage_now}=="12194000"
    ATTR{charge_full}=="3296000"
    ATTR{cycle_count}=="0"
    ATTR{type}=="Battery"
    ATTR{manufacturer}=="Hewlett-Packard"
    ATTR{capacity}=="99"
    ATTR{capacity_level}=="Normal"
    ATTR{model_name}=="Primary"
...
udevadm test /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0 2>&1>
...
BAT0: /etc/udev/rules.d/98-discharging.rules:1 RUN '/usr/bin/nbfc set -a'
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
POWER_SUPPLY_VOLTAGE_NOW=12126000
POWER_SUPPLY_CHARGE_FULL_DESIGN=3296000
POWER_SUPPLY_CHARGE_FULL=3296000
POWER_SUPPLY_CHARGE_NOW=3264000
POWER_SUPPLY_CAPACITY=99
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=Primary
POWER_SUPPLY_MANUFACTURER=Hewlett-Packard
POWER_SUPPLY_SERIAL_NUMBER= 
ACTION=add
SUBSYSTEM=power_supply
USEC_INITIALIZED=1715497275
[ins]run: '/usr/bin/nbfc set -a'[/ins]
Unload module index
Unloaded link configuration context.

The problem it's than they never get to be executed.

Looking through journal, I believe it has something to do with the fact than when the tlp rule kicks in, my rules just get ignored.

 
# tlp - udev rules
#
# Copyright (c) 2020 Thomas Koch <linrunner at gmx.net> and others.
# This software is licensed under the GPL v2 or later.

# handle change of power source ac/bat
ACTION=="change", SUBSYSTEM=="power_supply", RUN+="/usr/bin/tlp auto"

# handle added usb devices (exclude subdevices via DRIVER=="USB")
ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usb", ENV{DEVTYPE}=="usb_device", RUN+="/usr/lib/udev/tlp-usb-udev %p"

The section of journal -b with systemd-udevd entrys it's to big for this post, but this it's an stract from journal.

mar 27 12:47:35 systemd-udevd[286]: BAT0: Device (SEQNUM=3000, ACTION=change) is queued
mar 27 12:47:35 systemd-udevd[286]: Validate module index
mar 27 12:47:35 systemd-udevd[286]: Check if link configuration needs reloading.
mar 27 12:47:35 systemd-udevd[286]: Successfully forked off 'n/a' as PID 6406.
mar 27 12:47:35 systemd-udevd[286]: BAT0: Worker [6406] is forked for processing SEQNUM=3000.
mar 27 12:47:35 systemd-udevd[286]: BAT0: Device (SEQNUM=3001, ACTION=change) is queued
mar 27 12:47:35 systemd-udevd[6406]: BAT0: Processing device (SEQNUM=3000, ACTION=change)
mar 27 12:47:35 systemd-udevd[286]: ACAD: Device (SEQNUM=3002, ACTION=change) is queued
mar 27 12:47:35 systemd-udevd[286]: Successfully forked off 'n/a' as PID 6407.
mar 27 12:47:35 systemd-udevd[286]: ACAD: Worker [6407] is forked for processing SEQNUM=3002.
mar 27 12:47:35 systemd-udevd[6406]: BAT0: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:35 systemd-udevd[6407]: ACAD: Processing device (SEQNUM=3002, ACTION=change)
mar 27 12:47:35 systemd-udevd[6406]: BAT0: Running command "/usr/bin/tlp auto"
mar 27 12:47:35 systemd-udevd[6406]: BAT0: Starting '/usr/bin/tlp auto'
mar 27 12:47:35 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6408.
mar 27 12:47:35 systemd-udevd[6407]: ACAD: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:35 systemd-udevd[6407]: ACAD: Running command "/usr/bin/tlp auto"
mar 27 12:47:35 systemd-udevd[6407]: ACAD: Starting '/usr/bin/tlp auto'
mar 27 12:47:35 systemd-udevd[6407]: Successfully forked off '(spawn)' as PID 6409.
mar 27 12:47:36 systemd-udevd[6407]: ACAD: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:36 systemd-udevd[6407]: ACAD: Device (SEQNUM=3002, ACTION=change) processed
mar 27 12:47:36 systemd-udevd[6407]: ACAD: sd-device-monitor: Passed 233 byte to netlink monitor
mar 27 12:47:36 systemd-udevd[6406]: BAT0: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:36 systemd-udevd[6406]: BAT0: Device (SEQNUM=3000, ACTION=change) processed
mar 27 12:47:36 systemd-udevd[6406]: BAT0: sd-device-monitor: Passed 660 byte to netlink monitor
mar 27 12:47:36 systemd-udevd[286]: BAT0: sd-device-monitor: Passed 660 byte to netlink monitor
mar 27 12:47:36 systemd-udevd[6406]: BAT0: Processing device (SEQNUM=3001, ACTION=change)
mar 27 12:47:36 systemd-udevd[6406]: BAT0: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:36 systemd-udevd[6406]: BAT0: Running command "/usr/bin/tlp auto"
mar 27 12:47:36 systemd-udevd[6406]: BAT0: Starting '/usr/bin/tlp auto'
mar 27 12:47:36 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6456.
mar 27 12:47:37 systemd-udevd[6406]: BAT0: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:37 systemd-udevd[6406]: BAT0: Device (SEQNUM=3001, ACTION=change) processed
mar 27 12:47:37 systemd-udevd[6406]: BAT0: sd-device-monitor: Passed 660 byte to netlink monitor
mar 27 12:47:38 systemd-udevd[286]: BAT0: Device (SEQNUM=3003, ACTION=change) is queued
mar 27 12:47:38 systemd-udevd[286]: Validate module index
mar 27 12:47:38 systemd-udevd[286]: Check if link configuration needs reloading.
mar 27 12:47:38 systemd-udevd[286]: BAT0: sd-device-monitor: Passed 662 byte to netlink monitor
mar 27 12:47:38 systemd-udevd[6406]: BAT0: Processing device (SEQNUM=3003, ACTION=change)
mar 27 12:47:38 systemd-udevd[286]: BAT0: Device (SEQNUM=3004, ACTION=change) is queued
mar 27 12:47:38 systemd-udevd[286]: ACAD: Device (SEQNUM=3005, ACTION=change) is queued
mar 27 12:47:38 systemd-udevd[286]: ACAD: sd-device-monitor: Passed 233 byte to netlink monitor
mar 27 12:47:38 systemd-udevd[6407]: ACAD: Processing device (SEQNUM=3005, ACTION=change)
mar 27 12:47:38 systemd-udevd[6406]: BAT0: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:38 systemd-udevd[6406]: BAT0: Running command "/usr/bin/tlp auto"
mar 27 12:47:38 systemd-udevd[6407]: ACAD: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:38 systemd-udevd[6406]: BAT0: Starting '/usr/bin/tlp auto'
mar 27 12:47:38 systemd-udevd[6407]: ACAD: Running command "/usr/bin/tlp auto"
mar 27 12:47:38 systemd-udevd[6407]: ACAD: Starting '/usr/bin/tlp auto'
mar 27 12:47:38 systemd-udevd[6407]: Successfully forked off '(spawn)' as PID 6586.
mar 27 12:47:38 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6587.
mar 27 12:47:39 systemd-udevd[6407]: ACAD: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:39 systemd-udevd[6407]: ACAD: Device (SEQNUM=3005, ACTION=change) processed
mar 27 12:47:39 systemd-udevd[6407]: ACAD: sd-device-monitor: Passed 233 byte to netlink monitor
mar 27 12:47:39 systemd-udevd[6406]: BAT0: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:39 systemd-udevd[6406]: BAT0: Device (SEQNUM=3003, ACTION=change) processed
mar 27 12:47:39 systemd-udevd[6406]: BAT0: sd-device-monitor: Passed 662 byte to netlink monitor
mar 27 12:47:39 systemd-udevd[286]: BAT0: sd-device-monitor: Passed 662 byte to netlink monitor
mar 27 12:47:39 systemd-udevd[6406]: BAT0: Processing device (SEQNUM=3004, ACTION=change)
mar 27 12:47:39 systemd-udevd[6406]: BAT0: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:39 systemd-udevd[6406]: BAT0: Running command "/usr/bin/tlp auto"
mar 27 12:47:39 systemd-udevd[6406]: BAT0: Starting '/usr/bin/tlp auto'
mar 27 12:47:39 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6721.
mar 27 12:47:39 systemd-udevd[6406]: BAT0: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:39 systemd-udevd[6406]: BAT0: Device (SEQNUM=3004, ACTION=change) processed
mar 27 12:47:39 systemd-udevd[6406]: BAT0: sd-device-monitor: Passed 662 byte to netlink monitor
mar 27 12:47:42 systemd-udevd[286]: BAT0: Device (SEQNUM=3006, ACTION=change) is queued
mar 27 12:47:42 systemd-udevd[286]: Validate module index
mar 27 12:47:42 systemd-udevd[286]: Check if link configuration needs reloading.
mar 27 12:47:42 systemd-udevd[286]: BAT0: sd-device-monitor: Passed 663 byte to netlink monitor
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Processing device (SEQNUM=3006, ACTION=change)
mar 27 12:47:42 systemd-udevd[286]: BAT0: Device (SEQNUM=3007, ACTION=change) is queued
mar 27 12:47:42 systemd-udevd[6406]: BAT0: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:42 systemd-udevd[6406]: BAT0: /etc/udev/rules.d/97-charging.rules:1 RUN '/usr/bin/nbfc set -s 100'
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Running command "/usr/bin/tlp auto"
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Starting '/usr/bin/tlp auto'
mar 27 12:47:42 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6741.
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Running command "/usr/bin/nbfc set -s 100"
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Starting '/usr/bin/nbfc set -s 100'
mar 27 12:47:42 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6758.
mar 27 12:47:42 systemd-udevd[6406]: BAT0: '/usr/bin/nbfc set -s 100'(err) '/usr/bin/nbfc: line 3:  6759 Segmentation fault      (core dumped) mono /opt/n>
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Process '/usr/bin/nbfc set -s 100' failed with exit code 139.
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Command "/usr/bin/nbfc set -s 100" returned 139 (error), ignoring.
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Device (SEQNUM=3006, ACTION=change) processed
mar 27 12:47:42 systemd-udevd[6406]: BAT0: sd-device-monitor: Passed 663 byte to netlink monitor
mar 27 12:47:42 systemd-udevd[286]: BAT0: sd-device-monitor: Passed 663 byte to netlink monitor
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Processing device (SEQNUM=3007, ACTION=change)
mar 27 12:47:42 systemd-udevd[6406]: BAT0: /usr/lib/udev/rules.d/85-tlp.rules:7 RUN '/usr/bin/tlp auto'
mar 27 12:47:42 systemd-udevd[6406]: BAT0: /etc/udev/rules.d/97-charging.rules:1 RUN '/usr/bin/nbfc set -s 100'
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Running command "/usr/bin/tlp auto"
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Starting '/usr/bin/tlp auto'
mar 27 12:47:42 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6762.
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Process '/usr/bin/tlp auto' succeeded.
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Running command "/usr/bin/nbfc set -s 100"
mar 27 12:47:42 systemd-udevd[6406]: BAT0: Starting '/usr/bin/nbfc set -s 100'
mar 27 12:47:42 systemd-udevd[6406]: Successfully forked off '(spawn)' as PID 6783.
mar 27 12:47:42 systemd[1]: Started Process Core Dump (PID 6785/UID 0).
mar 27 12:47:43 systemd-udevd[6406]: BAT0: '/usr/bin/nbfc set -s 100'(err) '/usr/bin/nbfc: line 3:  6784 Segmentation fault      (core dumped) mono /opt/n>
mar 27 12:47:43 systemd-udevd[6406]: BAT0: Process '/usr/bin/nbfc set -s 100' failed with exit code 139.
mar 27 12:47:43 systemd-udevd[6406]: BAT0: Command "/usr/bin/nbfc set -s 100" returned 139 (error), ignoring.
mar 27 12:47:43 systemd-udevd[6406]: BAT0: Device (SEQNUM=3007, ACTION=change) processed
mar 27 12:47:43 systemd-udevd[6406]: BAT0: sd-device-monitor: Passed 663 byte to netlink monitor
mar 27 12:47:46 systemd-udevd[286]: Cleanup idle workers
mar 27 12:47:46 systemd-udevd[6406]: Unload module index
mar 27 12:47:46 systemd-udevd[6407]: Unload module index
mar 27 12:47:46 systemd-udevd[6406]: Unloaded link configuration context.
mar 27 12:47:46 systemd-udevd[6407]: Unloaded link configuration context.
mar 27 12:47:46 systemd-udevd[286]: Worker [6406] exited
mar 27 12:47:46 systemd-udevd[286]: Worker [6407] exited

When the run part gets to be executed, theres a segmentation dump, (dunno if its nbfc fault or mine).

Can someone point me to what I'm doing wrong?

Last edited by Ulilop (2020-03-28 02:31:20)

Offline

#2 2020-03-27 19:30:41

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,771

Re: Udev power_supply rule not working with tlp

Thank you for using BBCode, but please change your quote tags to code tags.  Thanks.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2020-03-28 02:30:20

Ulilop
Member
From: CDMX, México
Registered: 2020-03-27
Posts: 5

Re: Udev power_supply rule not working with tlp

ewaller wrote:

Thank you for using BBCode, but please change your quote tags to code tags.  Thanks.

Thank you for the advice, it's done.

Offline

#4 2020-03-28 07:37:36

Ulilop
Member
From: CDMX, México
Registered: 2020-03-27
Posts: 5

Re: Udev power_supply rule not working with tlp

I just tested the conditions for 99-lowbat.rules and still not working.

Offline

#5 2020-03-28 15:25:20

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,771

Re: Udev power_supply rule not working with tlp

I have no way of testing nbfc.  Can you run it from a shell without crashing?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2020-03-29 12:10:10

Ulilop
Member
From: CDMX, México
Registered: 2020-03-27
Posts: 5

Re: Udev power_supply rule not working with tlp

ewaller wrote:

I have no way of testing nbfc.  Can you run it from a shell without crashing?

Yes, when I use it on a terminal works perfectly fine. I searched for that problem and it turns out as a I/O error code, a permissions issue.
I don't really care about these two nbfc rules, they could be a nice addition, for battery performance. I will delete them for now, but maybe later they could work calling a script (the ENV could do a better job whit the I/O).

The rule that I really want to make work it's the hibernation one. And right now, still gets ignored :c

Offline

Board footer

Powered by FluxBB