feat(tazjin/emacs): add a monitor focus switch shortcut

This one is a bit stupid because I couldn't figure out a way to
determine the active workspace. It's definitely possible (either
through some XCB calls, or through state management in screen change
hooks), but for now this is fine.

Change-Id: I5e4c531b248caa0021664bad9dc196bef60cfbac
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10122
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
This commit is contained in:
Vincent Ambo 2023-11-25 18:15:11 +03:00 committed by clbot
parent 53008771ae
commit e400a9b027

View file

@ -407,8 +407,22 @@ given monitor and assigns a workspace to it."
(shell-command (format "xrandr --output %s --off" monitor))
(exwm-assign-workspaces)))
(defun exwm-switch-monitor ()
"Switch focus to another monitor by name."
(interactive)
;; TODO: Filter out currently active? How to determine it?
(let* ((target (completing-read "Switch to monitor: "
(seq-map #'car (cadr (exwm-randr--get-monitors)))
nil t))
(target-workspace
(cl-loop for (workspace screen) on exwm-randr-workspace-monitor-plist by #'cddr
when (equal screen target) return workspace)))
(exwm-workspace-switch target-workspace)))
(exwm-input-set-key (kbd "s-m e") #'exwm-enable-monitor)
(exwm-input-set-key (kbd "s-m d") #'exwm-disable-monitor)
(exwm-input-set-key (kbd "s-m o") #'exwm-switch-monitor)
;; Notmuch shortcuts as EXWM globals
;; (g m => gmail)