aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-21 06:37:18 -0500
committerCraig Jennings <c@cjennings.net>2026-07-21 06:37:18 -0500
commit4f28daa3754c69f9fb3288bc7cdb5858f047f009 (patch)
tree4a2654bdc2b06febfbe278c956cf499453272428 /modules
parent0fa283a3a828bd99260792a4fffd772b2cec5bc0 (diff)
downloaddotemacs-4f28daa3754c69f9fb3288bc7cdb5858f047f009.tar.gz
dotemacs-4f28daa3754c69f9fb3288bc7cdb5858f047f009.zip
fix(system): resolve the locker at command time, not module load
lockscreen-cmd baked (env-wayland-p) into a defvar at load, so a daemon started before WAYLAND_DISPLAY reached its environment froze the locker to slock and Lock failed silently on Wayland. The lock command now resolves per call, with lockscreen-cmd kept as an explicit override. Craig confirmed the fix over the decline option since it also makes the systemd unit path safe to revive.
Diffstat (limited to 'modules')
-rw-r--r--modules/system-commands.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/modules/system-commands.el b/modules/system-commands.el
index de5e8853..edc6339d 100644
--- a/modules/system-commands.el
+++ b/modules/system-commands.el
@@ -115,8 +115,21 @@ actions like shutdown and reboot), nil for no confirmation."
;; directly: logind emits the Lock signal, hypridle catches it and runs its
;; lock_cmd (hyprlock), the same path idle/before-sleep locking already uses.
;; X11 machines keep slock.
-(cj/defsystem-command cj/system-cmd-lock lockscreen-cmd
- (if (env-wayland-p) "loginctl lock-session" "slock"))
+;;
+;; Unlike its siblings, the locker is resolved at COMMAND time, not baked into
+;; the defvar at load: a daemon started before WAYLAND_DISPLAY reaches its
+;; environment would freeze the locker to slock forever, and Lock would then
+;; fail silently on Wayland. `lockscreen-cmd' stays as an override knob.
+(defvar lockscreen-cmd nil
+ "Explicit lock command, overriding session-type resolution when non-nil.")
+
+(defun cj/system-cmd-lock ()
+ "Lock the session, resolving the locker from the live session type.
+Runs `lockscreen-cmd' when set; otherwise `loginctl lock-session' on
+Wayland and slock on X11, decided per call via `env-wayland-p'."
+ (interactive)
+ (cj/system-cmd (or lockscreen-cmd
+ (if (env-wayland-p) "loginctl lock-session" "slock"))))
(cj/defsystem-command cj/system-cmd-suspend suspend-cmd "systemctl suspend" t)
(cj/defsystem-command cj/system-cmd-shutdown shutdown-cmd "systemctl poweroff" strong)
(cj/defsystem-command cj/system-cmd-reboot reboot-cmd "systemctl reboot" strong)