quickshell: suspend in session menu, lock-before-sleep on Gaming

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-09-05 11:56:46 +01:00
parent c9b69bf86f
commit 5195c60fb5
2 changed files with 7 additions and 2 deletions

View file

@ -71,7 +71,7 @@ in
# paints. A unit ordered Before=sleep.target genuinely blocks the # paints. A unit ordered Before=sleep.target genuinely blocks the
# suspend until it exits. The sleep covers the gap between quickshell # suspend until it exits. The sleep covers the gap between quickshell
# accepting the IPC and the lock surface committing a frame. # 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"; description = "Lock the session before suspend";
before = [ "sleep.target" ]; before = [ "sleep.target" ];
wantedBy = [ "sleep.target" ]; wantedBy = [ "sleep.target" ];

View file

@ -4833,6 +4833,7 @@ in
readonly property var actions: [ readonly property var actions: [
{ icon: "lock", danger: false, act: "lock" }, { icon: "lock", danger: false, act: "lock" },
{ icon: "moon", danger: false, act: "suspend" },
{ icon: "log-out", danger: false, act: "logout" }, { icon: "log-out", danger: false, act: "logout" },
{ icon: "rotate-ccw", danger: true, act: "reboot" }, { icon: "rotate-ccw", danger: true, act: "reboot" },
{ icon: "power", danger: true, act: "poweroff" } { icon: "power", danger: true, act: "poweroff" }
@ -4841,6 +4842,10 @@ in
function activate(act) { function activate(act) {
animateClose(); animateClose();
if (act === "lock") bar.shellRoot.lock(); 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 === "logout") Hyprland.dispatch("hl.dsp.exit()");
else if (act === "reboot") Quickshell.execDetached([Commands.systemctl, "reboot"]); else if (act === "reboot") Quickshell.execDetached([Commands.systemctl, "reboot"]);
else Quickshell.execDetached([Commands.systemctl, "poweroff"]); else Quickshell.execDetached([Commands.systemctl, "poweroff"]);
@ -4899,7 +4904,7 @@ in
SIcon { SIcon {
anchors.centerIn: parent anchors.centerIn: parent
text: sessBtn.modelData.icon text: sessBtn.modelData.icon
// All four buttons share the logout // All five buttons share the logout
// setup: base05, FILL on selection. // setup: base05, FILL on selection.
color: Theme.base05 color: Theme.base05
font.pixelSize: 20 font.pixelSize: 20