From 5195c60fb56d27b932e91dbf1df492335dc17dbc Mon Sep 17 00:00:00 2001 From: rope Date: Sat, 5 Sep 2026 11:56:46 +0100 Subject: [PATCH] quickshell: suspend in session menu, lock-before-sleep on Gaming Co-Authored-By: Claude Opus 5 --- settings/hyprland.nix | 2 +- settings/quickshell.nix | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/settings/hyprland.nix b/settings/hyprland.nix index 3cfc310..172bcf2 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -71,7 +71,7 @@ in # paints. A unit ordered Before=sleep.target genuinely blocks the # suspend until it exits. The sleep covers the gap between quickshell # accepting the IPC and the lock surface committing a frame. - systemd.services.lock-before-sleep = lib.mkIf isMacbook { + systemd.services.lock-before-sleep = { description = "Lock the session before suspend"; before = [ "sleep.target" ]; wantedBy = [ "sleep.target" ]; diff --git a/settings/quickshell.nix b/settings/quickshell.nix index 3b2b992..69251ce 100644 --- a/settings/quickshell.nix +++ b/settings/quickshell.nix @@ -4833,6 +4833,7 @@ in readonly property var actions: [ { icon: "lock", danger: false, act: "lock" }, + { icon: "moon", danger: false, act: "suspend" }, { icon: "log-out", danger: false, act: "logout" }, { icon: "rotate-ccw", danger: true, act: "reboot" }, { icon: "power", danger: true, act: "poweroff" } @@ -4841,6 +4842,10 @@ in function activate(act) { animateClose(); if (act === "lock") bar.shellRoot.lock(); + // No lock call here: systemd-suspend runs + // lock-before-sleep, which locks before the machine + // actually goes down (settings/hyprland.nix). + else if (act === "suspend") Quickshell.execDetached([Commands.systemctl, "suspend"]); else if (act === "logout") Hyprland.dispatch("hl.dsp.exit()"); else if (act === "reboot") Quickshell.execDetached([Commands.systemctl, "reboot"]); else Quickshell.execDetached([Commands.systemctl, "poweroff"]); @@ -4899,7 +4904,7 @@ in SIcon { anchors.centerIn: parent text: sessBtn.modelData.icon - // All four buttons share the logout + // All five buttons share the logout // setup: base05, FILL on selection. color: Theme.base05 font.pixelSize: 20