about summary refs log tree commit diff
path: root/users/wpcarro/emacs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-01-20T23·47-0800
committerclbot <clbot@tvl.fyi>2022-01-27T05·52+0000
commit6982ee618dfe8f94e5c00282b195142a8a4dede1 (patch)
tree7b603c359c87736935acf4e9135a2a84ba127ea3 /users/wpcarro/emacs
parentdb3223ab7c8fca53c321dbbf7afa7e296862044b (diff)
refactor(wpcarro/emacs): Drop window-manager-logout r/3681
TL;DR:
- undefine `window-manager-logout`
- define window-manager customization group
- publicize `window-manager--xsecurelock`
- rename `window-manager--xsecurelock` -> `window-manager-screenlocker`
- remap `workspace "l"` to always lock the screen

Change-Id: I77df883b94e786c4584351c9ebf1dcf0d5a84a33
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5035
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/wpcarro/emacs')
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/keybindings.el5
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/window-manager.el63
2 files changed, 8 insertions, 60 deletions
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
index 5b137b75dc..d6e9d60d11 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
@@ -178,7 +178,10 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Workspaces
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(keybindings-exwm (kbd-raw 'workspace "l") #'window-manager-logout)
+(keybindings-exwm (kbd-raw 'workspace "l")
+                  (lambda ()
+                    (interactive)
+                    (shell-command window-manager-screenlocker)))
 
 (general-define-key
  :keymaps 'override
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/window-manager.el b/users/wpcarro/emacs/.emacs.d/wpc/window-manager.el
index 4b9735b961..4a9f4cabb5 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/window-manager.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/window-manager.el
@@ -56,6 +56,7 @@
 ;; between workspaces.
 
 (cl-defstruct window-manager--named-workspace label kbd display)
+(defgroup window-manager)
 
 (defconst window-manager--install-kbds? t
   "When t, install the keybindings to switch between named-workspaces.")
@@ -124,6 +125,9 @@
           ;; TODO: Ensure C-c copies.
           ([?\C-c] . [C-c])))
   (exwm-enable))
+(defcustom window-manager-screenlocker "xsecurelock"
+  "Reference to a screen-locking executable."
+  :group 'window-manager)
 
 ;; Here is the code required to allow EXWM to cycle workspaces.
 (defconst window-manager--workspaces
@@ -185,65 +189,6 @@
 ;; can provide a small mode for accepting user-input.
 ;; TODO: Put this somewhere more diliberate.
 
-;; TODO: Configure the environment variables for xsecurelock so that the font is
-;; smaller, different, and the glinux wallpaper doesn't show.
-;; - XSECURELOCK_FONT="InputMono-Black 10"
-;; - XSECURE_SAVER=""
-;; - XSECURE_LOGO_IMAGE=""
-;; Maybe just create a ~/.xsecurelockrc
-;; TODO: Is there a shell-command API that accepts an alist and serializes it
-;; into variables to pass to the shell command?
-(defconst window-manager--xsecurelock
-  (if (device-corporate?)
-      "/usr/share/goobuntu-desktop-files/xsecurelock.sh"
-    "xsecurelock")
-  "Path to the proper xsecurelock executable.
-The other path to xsecurelock is /usr/bin/xsecurelock, which works fine, but it
-is not optimized for Goobuntu devices.  Goobuntu attempts to check a user's
-password using the network.  When there is no network connection available, the
-login attempts fail with an \"unknown error\", which isn't very helpful.  To
-avoid this, prefer the goobuntu wrapper around xsecurelock when on a goobuntu
-device.  This all relates to PAM (i.e. pluggable authentication modules).")
-
-(defun window-manager-logout ()
-  "Prompt the user for options for logging out, shutting down, etc.
-
-The following options are supported:
-- Lock
-- Logout
-- Suspend
-- Hibernate
-- Reboot
-- Shutdown
-
-Ivy is used to capture the user's input."
-  (interactive)
-  (let* ((name->cmd `(("Lock" .
-                       (lambda ()
-                         (shell-command window-manager--xsecurelock)))
-                      ("Logout" .
-                       (lambda ()
-                         (let ((default-directory "/sudo::"))
-                           (shell-command "systemctl restart gdm.service"))))
-                      ("Suspend" .
-                       (lambda ()
-                         (shell-command "systemctl suspend")))
-                      ("Hibernate" .
-                       (lambda ()
-                         (shell-command "systemctl hibernate")))
-                      ("Reboot" .
-                       (lambda ()
-                         (let ((default-directory "/sudo::"))
-                           (shell-command "reboot"))))
-                      ("Shutdown" .
-                       (lambda ()
-                         (let ((default-directory "/sudo::"))
-                           (shell-command "shutdown now")))))))
-    (funcall
-     (lambda ()
-       (funcall (al-get (ivy-read "System: " (al-keys name->cmd))
-                        name->cmd))))))
-
 (defun window-manager--label->index (label workspaces)
   "Return the index of the workspace in WORKSPACES named LABEL."
   (let ((index (-elem-index label (-map #'window-manager--named-workspace-label