Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 380933 - sys-apps/openrc: on_ac_power misses "ADP1" adapters
Summary: sys-apps/openrc: on_ac_power misses "ADP1" adapters
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 387433
  Show dependency tree
 
Reported: 2011-08-28 11:55 UTC by Alexei Ababilov
Modified: 2011-11-17 18:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to fix AC adapter presence recognition (openrc-0.8.3-on_ac_power.patch,986 bytes, patch)
2011-08-28 11:55 UTC, Alexei Ababilov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexei Ababilov 2011-08-28 11:55:38 UTC
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 1 SpanKY gentoo-dev 2011-08-28 22:50:45 UTC
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.
Comment 2 Alexei Ababilov 2011-09-01 08:19:16 UTC
(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
Comment 3 SpanKY gentoo-dev 2011-09-17 23:06:46 UTC
(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
Comment 4 William Hubbs gentoo-dev 2011-11-17 18:30:11 UTC
This was applied in commit 260b61e.

Thanks for the report.