power-action: use upstream writers

This commit is contained in:
lassulus 2023-09-04 20:36:51 +02:00
parent 245dd8b67f
commit 5e215d87e5

View file

@ -60,7 +60,7 @@ let
}; };
}; };
startScript = pkgs.writeDash "power-action" '' startScript = pkgs.writers.writeDash "power-action" ''
set -euf set -euf
power="$(${powerlvl})" power="$(${powerlvl})"
@ -77,11 +77,11 @@ let
writeRule = _: plan: writeRule = _: plan:
"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.writers.writeDash "powerlvl" ''
cat /sys/class/power_supply/${cfg.battery}/capacity cat /sys/class/power_supply/${cfg.battery}/capacity
''; '';
state = pkgs.writeDash "state" '' state = pkgs.writers.writeDash "state" ''
if [ "$(cat /sys/class/power_supply/${cfg.battery}/status)" = "Discharging" ] if [ "$(cat /sys/class/power_supply/${cfg.battery}/status)" = "Discharging" ]
then echo "false" then echo "false"
else echo "true" else echo "true"