Created attachment 284865 [details, diff] patch to fix AC adapter presence recognition On several machines, a file corresponding to AC adapter can be named ADP1 or in another way. However, on_ac_power script checks for file by template AC*. Obviously, ADP1 doesn't match AC* and the script always considers that AC adapter is off.
Comment on attachment 284865 [details, diff] patch to fix AC adapter presence recognition the first part (/proc/acpi/ac_adapter/*) is fine, but the 2nd is probably not. i'm pretty the "power_supply" class in the kernel can apply to individual components.
(In reply to comment #1) > Comment on attachment 284865 [details, diff] > patch to fix AC adapter presence recognition > > the first part (/proc/acpi/ac_adapter/*) is fine, but the 2nd is probably not. > i'm pretty the "power_supply" class in the kernel can apply to individual > components. According to /usr/bin/on_ac_power (from sys-power/pm-utils), it's ok to check "online" in /sys/class/power_supply/* : for ps in /sys/class/power_supply/*; do [ -r "$ps/online" ] || continue # OK, we know we have an AC adaptor. # Our default return changes to failed. ret=1 read -r ps_status < "$ps/online" [ 1 -eq "$ps_status" ] && exit 0 done Battery doesn't have an "online" file: $ ls /sys/class/power_supply/BAT0/online ls: cannot access /sys/class/power_supply/BAT0/online: No such file or directory
(In reply to comment #2) i'm not sure the assumption is valid, but if it's good enough for the pm-utils package, then it's probably fine for us as well
This was applied in commit 260b61e. Thanks for the report.