openrc/scripts
Sven Wegener 63955056ec on_ac_power: support multiple power_supply devices in sysfs
Newer devices have multiple power_supply devices in sysfs:

$ grep ^ /sys/class/power_supply/*/type
/sys/class/power_supply/AC/type:Mains
/sys/class/power_supply/BAT0/type:Battery
/sys/class/power_supply/ucsi-source-psy-USBC000:001/type:USB
/sys/class/power_supply/ucsi-source-psy-USBC000:002/type:USB

There are two "USB" Type-C ports than can supply power and both are
aggregated into the "Mains" power supply by the firmware. The "Battery"
also counts as a power supply, but is missing the online attribute.

The -f check with a wildcard pattern results in an error, when multiple
devices are present:

/lib/rc/bin/on_ac_power: line 21: [: too many arguments

When the power_supply class is registered, check for a "Mains" device.

Fixes #427.
2021-08-13 13:38:07 -05:00
..
.gitignore openrc-init: add optional sysvinit compatibility 2017-05-31 18:07:02 -05:00
halt.in scripts: fix halt, poweroff and reboot wrappers 2018-12-27 13:52:16 -06:00
Makefile Fix link to shutdown for MKSYSVINIT=yes 2017-06-12 12:12:50 -05:00
on_ac_power on_ac_power: support multiple power_supply devices in sysfs 2021-08-13 13:38:07 -05:00
poweroff.in scripts: fix halt, poweroff and reboot wrappers 2018-12-27 13:52:16 -06:00
rc-sstat.in standardize the default shell 2018-12-08 12:06:26 -06:00
reboot.in scripts: fix halt, poweroff and reboot wrappers 2018-12-27 13:52:16 -06:00
shutdown.in scripts/shutdown.in: fix sysvinit compatible shutdown 2020-11-20 14:57:04 -06:00