From 52599fd24d1d7597d5521a5ea22aea8de5e5fcbd Mon Sep 17 00:00:00 2001 From: rope Date: Sun, 16 Aug 2026 13:34:38 +0100 Subject: [PATCH] lock-before-sleep: derive XDG_RUNTIME_DIR at runtime, %U was root --- settings/hyprland.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/settings/hyprland.nix b/settings/hyprland.nix index 1125d4c..8a936e4 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -76,11 +76,16 @@ in before = [ "sleep.target" ]; wantedBy = [ "sleep.target" ]; serviceConfig = { - Type = "oneshot"; - User = "fred"; - Environment = "XDG_RUNTIME_DIR=/run/user/%U"; - ExecStart = "${pkgs.quickshell}/bin/qs ipc call lock lock"; - ExecStartPost = "${pkgs.coreutils}/bin/sleep 1"; + Type = "oneshot"; + User = "fred"; + # XDG_RUNTIME_DIR must be derived at runtime: the %U specifier is the + # UID of the *manager* running the unit (0 for system units), not the + # one in User=, so it pointed qs at /run/user/0. + ExecStart = pkgs.writeShellScript "lock-before-sleep" '' + export XDG_RUNTIME_DIR=/run/user/$(${pkgs.coreutils}/bin/id -u) + ${pkgs.quickshell}/bin/qs ipc call lock lock + ${pkgs.coreutils}/bin/sleep 1 + ''; TimeoutStartSec = "5s"; }; };