From e2460ca093b6e552157c5dfbfadf8f7365352ec0 Mon Sep 17 00:00:00 2001 From: alejandro-angulo Date: Fri, 17 Apr 2026 19:30:05 -0700 Subject: [PATCH] Prevent undesirable suspends hypridle only suspends if not connected to an external monitor and logind no longer suspends while charging --- modules/home/services/hypridle/default.nix | 7 ++++--- systems/x86_64-linux/framework/default.nix | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/home/services/hypridle/default.nix b/modules/home/services/hypridle/default.nix index 6b082a9..d73a8c5 100644 --- a/modules/home/services/hypridle/default.nix +++ b/modules/home/services/hypridle/default.nix @@ -15,10 +15,11 @@ let cfg = config.${namespace}.services.hypridle; - # Script that suspends only when on battery power. + # Script that suspends only when not docked (no external monitors). suspendScript = pkgs.writeShellScript "hypridle-suspend" '' - if [ "$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/AC/online)" != "1" ]; then - # On battery - suspend + mon_count=$(${pkgs.hyprland}/bin/hyprctl monitors all 2>/dev/null | ${pkgs.gnugrep}/bin/grep -c '^Monitor' || echo "0") + # If only 1 monitor (builtin), suspend. If 2+ monitors, assume docked - don't suspend. + if [ "$mon_count" -le 1 ]; then ${pkgs.systemd}/bin/systemctl suspend fi ''; diff --git a/systems/x86_64-linux/framework/default.nix b/systems/x86_64-linux/framework/default.nix index c5c11be..66c9c37 100644 --- a/systems/x86_64-linux/framework/default.nix +++ b/systems/x86_64-linux/framework/default.nix @@ -46,6 +46,12 @@ services.fwupd.enable = true; services.gvfs.enable = true; + services.logind.settings.Login = { + HandleLidSwitchDocked = "ignore"; + HandleLidSwitchExternalPower = "ignore"; + HandleLidSwitch = "suspend"; + KillUserProcesses = false; + }; virtualisation = { docker = {