From e400a9b027248056130877569f7833f37a0c2fd1 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 25 Nov 2023 18:15:11 +0300 Subject: 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 Autosubmit: tazjin --- users/tazjin/emacs/config/desktop.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'users/tazjin/emacs') diff --git a/users/tazjin/emacs/config/desktop.el b/users/tazjin/emacs/config/desktop.el index 7bb15da85c..4c64e7e70d 100644 --- a/users/tazjin/emacs/config/desktop.el +++ b/users/tazjin/emacs/config/desktop.el @@ -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) -- cgit 1.4.1