about summary refs log tree commit diff
path: root/users/tazjin/emacs/config
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@tvl.su>2023-11-25T15·15+0300
committerclbot <clbot@tvl.fyi>2023-11-25T15·24+0000
commite400a9b027248056130877569f7833f37a0c2fd1 (patch)
tree15b7d51b7dc19867fd43634e0e1ea63d00790299 /users/tazjin/emacs/config
parent53008771ae57d229bb7eb642aefeb65a08bcb9d1 (diff)
feat(tazjin/emacs): add a monitor focus switch shortcut r/7058
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>
Diffstat (limited to 'users/tazjin/emacs/config')
-rw-r--r--users/tazjin/emacs/config/desktop.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/users/tazjin/emacs/config/desktop.el b/users/tazjin/emacs/config/desktop.el
index 7bb15da85c7d..4c64e7e70d50 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)