diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-04 10:28:07 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-04 10:28:53 -0700 |
commit | 4fc37e152b9dfb632c3d6c3c7744889aa408ff12 (patch) | |
tree | 9bcbb6bd5cc44c75bd8e184a3a2ccf8da0206c0b | |
parent | 70004a851e5c0e9f1907abd33794e32f6c390e9e (diff) | |
download | dotfiles-4fc37e152b9dfb632c3d6c3c7744889aa408ff12.tar.gz |
update Emacs session management code to handle sway
-rw-r--r-- | .emacs.d/init-spw.el | 39 | ||||
-rwxr-xr-x | bin/update-emacs-daemon-environment | 4 |
2 files changed, 28 insertions, 15 deletions
diff --git a/.emacs.d/init-spw.el b/.emacs.d/init-spw.el index d6e81a6b..80d23d35 100644 --- a/.emacs.d/init-spw.el +++ b/.emacs.d/init-spw.el @@ -129,16 +129,19 @@ add places the library might be available to `load-path'." string)) (defun spw/get-wm () - (when (executable-find "wmctrl") - (let (wm - (display-env (getenv "DISPLAY"))) - (unwind-protect - (progn - (setenv "DISPLAY" (frame-parameter (selected-frame) 'display)) - (setq wm (nth 1 - (split-string (car (process-lines "wmctrl" "-m")))))) - (setenv "DISPLAY" display-env)) - wm))) + (if (string= (getenv "XDG_SESSION_TYPE") "wayland") + (getenv "XDG_CURRENT_DESKTOP") + (when (executable-find "wmctrl") + (let (wm + (display-env (getenv "DISPLAY"))) + (unwind-protect + (progn + (setenv "DISPLAY" (frame-parameter (selected-frame) 'display)) + (setq wm (nth + 1 + (split-string (car (process-lines "wmctrl" "-m")))))) + (setenv "DISPLAY" display-env)) + wm)))) ;;;; Startup & basic preferences @@ -191,8 +194,9 @@ add places the library might be available to `load-path'." (defun spw/tiling-window-manager-setup (&rest _ignore) "Change settings for optimal usage if we have frames running under i3." - (if (member "i3" (mapcar (lambda (f) (frame-parameter f 'spw/window-manager)) - (frame-list))) + (if (cl-find-if (lambda (e) (member e '("i3" "sway"))) + (mapcar (lambda (f) (frame-parameter f 'spw/window-manager)) + (frame-list))) (progn (setq mouse-autoselect-window t focus-follows-mouse t @@ -224,8 +228,9 @@ add places the library might be available to `load-path'." Should be t when do not have a good way to handle having lots of open frames, as I do have under i3 with its tabbed layout (which I use by default)." - (or (not (memq (framep (selected-frame)) '(x))) - (not (member (frame-parameter nil 'spw/window-manager) '("i3"))))) + (or (not (memq (framep (selected-frame)) '(x pgtk))) + (not (member (frame-parameter nil 'spw/window-manager) + '("i3" "sway"))))) ;; choice of font and size is driven by aim to fit eighty columns of ;; text in both halves of my laptop's monitor @@ -1928,13 +1933,17 @@ updated our environment variables, propagate to subenvironments. Called by that script using emacsclient(1)." (dolist (var '("DISPLAY" + "WAYLAND_DISPLAY" "SSH_ASKPASS" "SSH_AUTH_SOCK" "SSH_AGENT_PID" "SSH_CONNECTION" "WINDOWID" "XAUTHORITY" - "I3SOCK")) + "XDG_SESSION_TYPE" + "XDG_CURRENT_SESSION" + "I3SOCK" + "SWAYSOCK")) (when-let ((new-value (getenv var))) (dolist (buffer (buffer-list)) ;; 1. Eshells diff --git a/bin/update-emacs-daemon-environment b/bin/update-emacs-daemon-environment index 8b956ec0..9c1abf17 100755 --- a/bin/update-emacs-daemon-environment +++ b/bin/update-emacs-daemon-environment @@ -10,12 +10,16 @@ which emacsclient >/dev/null || exit 0 for var in DISPLAY \ + WAYLAND_DISPLAY \ SSH_ASKPASS \ SSH_AUTH_SOCK \ SSH_AGENT_PID \ SSH_CONNECTION \ WINDOWID \ XAUTHORITY \ + XDG_SESSION_TYPE \ + XDG_CURRENT_DESKTOP \ + SWAYSOCK \ I3SOCK; do eval isset=\${$var+x} if [ "$isset" = "x" ]; then |