From 650c9297d854b46e5009473767e2914653c99fec Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 22 Jan 2024 10:52:22 +0100 Subject: q-power_supply: handle Mains type --- pkgs/simple/q-power_supply.nix | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'pkgs') diff --git a/pkgs/simple/q-power_supply.nix b/pkgs/simple/q-power_supply.nix index 5e7cd0d..b7e5aaa 100644 --- a/pkgs/simple/q-power_supply.nix +++ b/pkgs/simple/q-power_supply.nix @@ -7,11 +7,25 @@ writeDashBin "q-power_supply" '' eval "$(${gnused}/bin/sed -n ' s/^\([A-Z_]\+=[0-9A-Za-z_-]*\)$/export \1/p ' $uevent)" - case $POWER_SUPPLY_NAME in - AC|Mains) - exit # not battery + case $POWER_SUPPLY_TYPE in + Battery) + power_supply_battery "$uevent" + ;; + Mains) + power_supply_mains "$uevent" + ;; + UPS|USB|Wireless) + echo "$uevent: warning: unsuppoerted type: $POWER_SUPPLY_TYPE" >&2 + exit 1 + ;; + *) + echo "$uevent: warning: unknown type: $POWER_SUPPLY_TYPE" >&2 + exit 2 ;; esac + )} + + power_supply_battery() {( exec