l 3 power-action: add option for battery
This commit is contained in:
parent
2db6515213
commit
54e6eecc92
|
@ -12,6 +12,10 @@ let
|
||||||
|
|
||||||
api = {
|
api = {
|
||||||
enable = mkEnableOption "power-action";
|
enable = mkEnableOption "power-action";
|
||||||
|
battery = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "BAT0";
|
||||||
|
};
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.user;
|
type = types.user;
|
||||||
default = {
|
default = {
|
||||||
|
@ -80,11 +84,11 @@ let
|
||||||
"if [ $power -ge ${toString plan.lowerLimit} ] && [ $power -le ${toString plan.upperLimit} ] ${charging_check plan}; then ${plan.action}; fi";
|
"if [ $power -ge ${toString plan.lowerLimit} ] && [ $power -le ${toString plan.upperLimit} ] ${charging_check plan}; then ${plan.action}; fi";
|
||||||
|
|
||||||
powerlvl = pkgs.writeDash "powerlvl" ''
|
powerlvl = pkgs.writeDash "powerlvl" ''
|
||||||
cat /sys/class/power_supply/BAT0/capacity
|
cat /sys/class/power_supply/${cfg.battery}/capacity
|
||||||
'';
|
'';
|
||||||
|
|
||||||
state = pkgs.writeDash "state" ''
|
state = pkgs.writeDash "state" ''
|
||||||
if [ "$(cat /sys/class/power_supply/BAT0/status)" = "Discharging" ]
|
if [ "$(cat /sys/class/power_supply/${cfg.battery}/status)" = "Discharging" ]
|
||||||
then echo "false"
|
then echo "false"
|
||||||
else echo "true"
|
else echo "true"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue