Fixed sleep when plugged in
Some checks failed
Build NixOS Configurations / build (carbon) (push) Has been cancelled
Build NixOS Configurations / build (git) (push) Has been cancelled
Build NixOS Configurations / build (gospel) (push) Has been cancelled
Build NixOS Configurations / build (node) (push) Has been cancelled

This commit is contained in:
alejandro-angulo 2026-04-04 18:26:57 -07:00
parent 549d9ee251
commit 99061b65da

View file

@ -16,12 +16,8 @@ let
cfg = config.${namespace}.services.hypridle;
# Script that suspends only when on battery power.
# When plugged in, uses systemd-inhibit to block suspend.
suspendScript = pkgs.writeShellScript "hypridle-suspend" ''
if [ "$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/AC/online)" = "1" ]; then
# Plugged in - inhibit suspend
${pkgs.systemd}/bin/systemd-inhibit --what=sleep --who=hypridle --why="AC power connected" --mode=block ${pkgs.coreutils}/bin/sleep infinity &
else
if [ "$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/AC/online)" != "1" ]; then
# On battery - suspend
${pkgs.systemd}/bin/systemctl suspend
fi