Apply nixfmt
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
enabled = config.mod.power.enable;
|
||||
lowbat = config.mod.lowbat;
|
||||
@@ -39,8 +44,8 @@ in
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
START_CHARGE_THRESH_BAT0=75;
|
||||
STOP_CHARGE_THRESH_BAT0=80;
|
||||
START_CHARGE_THRESH_BAT0 = 75;
|
||||
STOP_CHARGE_THRESH_BAT0 = 80;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -58,7 +63,7 @@ in
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
wantedBy = ["timers.target"];
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -78,28 +83,30 @@ in
|
||||
pkgs.swaylock
|
||||
];
|
||||
|
||||
script = let
|
||||
pause-music = "${pkgs.playerctl}/bin/playerctl -p spotify pause";
|
||||
in ''
|
||||
BATTERY_CAPACITY=$(cat /sys/class/power_supply/${lowbat.battery}/capacity)
|
||||
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
||||
echo "Battery capacity: $BATTERY_CAPACITY"
|
||||
echo "Battery status: $BATTERY_STATUS"
|
||||
|
||||
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.notifyCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
||||
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
||||
fi
|
||||
|
||||
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.suspendCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
||||
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Suspending in 60 seconds if power is not plugged in"
|
||||
sleep 60s
|
||||
|
||||
script =
|
||||
let
|
||||
pause-music = "${pkgs.playerctl}/bin/playerctl -p spotify pause";
|
||||
in
|
||||
''
|
||||
BATTERY_CAPACITY=$(cat /sys/class/power_supply/${lowbat.battery}/capacity)
|
||||
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
||||
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
||||
${pause-music}; ${pkgs.swaylock}/bin/swaylock -f; systemctl suspend
|
||||
echo "Battery capacity: $BATTERY_CAPACITY"
|
||||
echo "Battery status: $BATTERY_STATUS"
|
||||
|
||||
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.notifyCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
||||
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
|
||||
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.suspendCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
||||
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Suspending in 60 seconds if power is not plugged in"
|
||||
sleep 60s
|
||||
|
||||
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
||||
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
||||
${pause-music}; ${pkgs.swaylock}/bin/swaylock -f; systemctl suspend
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user