diff --git a/hosts/FredOS-Macbook.nix b/hosts/FredOS-Macbook.nix index 793ae94..809986b 100644 --- a/hosts/FredOS-Macbook.nix +++ b/hosts/FredOS-Macbook.nix @@ -21,6 +21,11 @@ boot.loader.systemd-boot.configurationLimit = 5; boot.initrd.systemd.enable = true; + services.logind = { + lidSwitch = "suspend"; + lidSwitchExternalPower = "suspend"; + }; + home-manager.users.fred = { ... }: { wayland.windowManager.hyprland.settings.monitor = [ ",preferred,auto,auto" ]; diff --git a/settings/hyprland.nix b/settings/hyprland.nix index d8be720..550b15c 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -136,7 +136,7 @@ in "wl-paste --type text --watch cliphist store" "wl-paste --type image --watch cliphist store" "hyprctl setcursor Bibata-Modern-Ice 24" - ]; + ] ++ lib.optionals isMacbook [ "hypridle" ]; general = { gaps_in = 6; @@ -373,6 +373,34 @@ in ''; }; + programs.hyprlock.enable = true; + + services.hypridle = lib.mkIf isMacbook { + enable = true; + settings = { + general = { + lock_cmd = "pidof hyprlock || hyprlock"; + before_sleep_cmd = "loginctl lock-session"; + after_sleep_cmd = "hyprctl dispatch dpms on"; + }; + listener = [ + { + timeout = 300; # 5 min — lock + on-timeout = "loginctl lock-session"; + } + { + timeout = 420; # 7 min — display off + on-timeout = "hyprctl dispatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + { + timeout = 600; # 10 min — suspend + on-timeout = "systemctl suspend"; + } + ]; + }; + }; + # Scope all HM Wayland services (hyprpaper, waybar, …) to the # Hyprland session so they don't crash-loop in a GNOME session. wayland.systemd.target = "hyprland-session.target";