Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 380933

Summary: sys-apps/openrc: on_ac_power misses "ADP1" adapters
Product: Gentoo Hosted Projects Reporter: Alexei Ababilov <ilovegnulinux>
Component: OpenRCAssignee: OpenRC Team <openrc>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 387433    
Attachments: patch to fix AC adapter presence recognition

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.