32 lines
901 B
Nix
32 lines
901 B
Nix
{ pkgs, ... }:
|
|
{
|
|
systemd.timers."batterylight" = {
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnBootSec = "5m";
|
|
OnUnitActiveSec = "5m";
|
|
Unit = "batterylight.service";
|
|
};
|
|
};
|
|
|
|
systemd.services."batterylight" = {
|
|
script = ''
|
|
STATUS=`cat /sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT1/status`
|
|
PERCENT=`cat /sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT1/capacity`
|
|
if [[ $STATUS == "Discharging" && $PERCENT -lt 10 ]]; then
|
|
for i in `seq 0 3`; do
|
|
${pkgs.framework-tool}/bin/framework_tool --kblight 0
|
|
sleep 0.2
|
|
${pkgs.framework-tool}/bin/framework_tool --kblight 100
|
|
sleep 0.2
|
|
${pkgs.framework-tool}/bin/framework_tool --kblight 0
|
|
sleep 0.2
|
|
done
|
|
fi
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = "root";
|
|
};
|
|
};
|
|
}
|