mirror of
https://github.com/SqrtMinusOne/dotfiles.git
synced 2025-12-10 19:23:03 +03:00
feat(exwm): better mechanism to switch between monitors
This commit is contained in:
parent
62eba36159
commit
5a3ff8d255
2 changed files with 72 additions and 70 deletions
|
|
@ -219,28 +219,41 @@ _d_: Discord
|
||||||
(setq mouse-autoselect-window t)
|
(setq mouse-autoselect-window t)
|
||||||
(setq focus-follows-mouse t)
|
(setq focus-follows-mouse t)
|
||||||
|
|
||||||
(setq my/exwm-monitor-workspace '())
|
(setq my/exwm-last-workspaces '(1))
|
||||||
|
|
||||||
(defun my/exwm-get-current-monitor ()
|
(defun my/exwm-store-last-workspace ()
|
||||||
(if (plist-get exwm-randr-workspace-monitor-plist exwm-workspace-current-index)
|
(setq my/exwm-last-workspaces
|
||||||
1 0))
|
(seq-uniq (cons exwm-workspace-current-index
|
||||||
|
my/exwm-last-workspaces))))
|
||||||
(defun my/exwm-update-current-monitor ()
|
|
||||||
(setf (alist-get (my/exwm-get-current-monitor) my/exwm-monitor-workspace)
|
|
||||||
exwm-workspace-current-index))
|
|
||||||
|
|
||||||
(add-hook 'exwm-workspace-switch-hook
|
(add-hook 'exwm-workspace-switch-hook
|
||||||
#'my/exwm-update-current-monitor)
|
#'my/exwm-store-last-workspace)
|
||||||
(defun my/exwm-switch-to-other-monitor ()
|
(defun my/exwm-switch-to-other-monitor ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((current (my/exwm-get-current-monitor))
|
(let* ((current-monitor
|
||||||
(other (seq-some
|
(plist-get exwm-randr-workspace-output-plist
|
||||||
(lambda (m)
|
(cl-position (selected-frame)
|
||||||
(and (not (= (car m) current)) (cdr m)))
|
exwm-workspace--list)))
|
||||||
my/exwm-monitor-workspace))
|
(all-monitors
|
||||||
(focus-follows-mouse nil)
|
(seq-uniq
|
||||||
(mouse-autoselect-window nil))
|
(cons nil
|
||||||
(exwm-workspace-switch other)))
|
(cl-loop for (key value) on exwm-randr-workspace-output-plist
|
||||||
|
by 'cddr collect value))))
|
||||||
|
(other-monitor
|
||||||
|
(nth
|
||||||
|
(% (1+ (cl-position current-monitor all-monitors))
|
||||||
|
(length all-monitors))
|
||||||
|
all-monitors)))
|
||||||
|
(exwm-workspace-switch
|
||||||
|
(cl-loop for i in (append my/exwm-last-workspaces
|
||||||
|
(cl-loop for i from 0
|
||||||
|
for _ in exwm-workspace--list
|
||||||
|
collect i))
|
||||||
|
if (if other-monitor
|
||||||
|
(string-equal (plist-get exwm-randr-workspace-output-plist i)
|
||||||
|
other-monitor)
|
||||||
|
(not (plist-get exwm-randr-workspace-output-plist i)))
|
||||||
|
return i))))
|
||||||
(setq exwm-input-prefix-keys
|
(setq exwm-input-prefix-keys
|
||||||
`(?\C-x
|
`(?\C-x
|
||||||
?\C-w
|
?\C-w
|
||||||
|
|
@ -342,23 +355,11 @@ _d_: Discord
|
||||||
(interactive)
|
(interactive)
|
||||||
(exwm-workspace-switch-create ,i))))
|
(exwm-workspace-switch-create ,i))))
|
||||||
(number-sequence 0 9))))
|
(number-sequence 0 9))))
|
||||||
(defvar my/exwm-mode-line-info "")
|
(use-package exwm-modeline
|
||||||
|
:straight (:host github :repo "SqrtMinusOne/exwm-modeline")
|
||||||
(add-to-list 'mode-line-misc-info
|
:after (exwm)
|
||||||
'(:eval my/exwm-mode-line-info))
|
:config
|
||||||
|
(add-hook 'exwm-init-hook #'exwm-modeline-mode))
|
||||||
(defun my/exwm-mode-line-info-update ()
|
|
||||||
(setq my/exwm-mode-line-info
|
|
||||||
(concat
|
|
||||||
"["
|
|
||||||
(propertize (funcall exwm-workspace-index-map exwm-workspace-current-index)
|
|
||||||
'face
|
|
||||||
`(foreground-color . ,(doom-color 'yellow)))
|
|
||||||
"]"))
|
|
||||||
(setq my/exwm-mode-line-info-no-props (funcall exwm-workspace-index-map exwm-workspace-current-index))
|
|
||||||
(force-mode-line-update))
|
|
||||||
|
|
||||||
(add-hook 'exwm-workspace-switch-hook #'my/exwm-mode-line-info-update)
|
|
||||||
(defun exwm-input--fake-last-command ()
|
(defun exwm-input--fake-last-command ()
|
||||||
"Fool some packages into thinking there is a change in the buffer."
|
"Fool some packages into thinking there is a change in the buffer."
|
||||||
(setq last-command #'exwm-input--noop)
|
(setq last-command #'exwm-input--noop)
|
||||||
|
|
|
||||||
73
Desktop.org
73
Desktop.org
|
|
@ -345,23 +345,11 @@ allow-loopback-pinentry
|
||||||
Show the current workspace in the modeline.
|
Show the current workspace in the modeline.
|
||||||
|
|
||||||
#+begin_src emacs-lisp :noweb-ref exwm-mode-line-config :tangle no
|
#+begin_src emacs-lisp :noweb-ref exwm-mode-line-config :tangle no
|
||||||
(defvar my/exwm-mode-line-info "")
|
(use-package exwm-modeline
|
||||||
|
:straight (:host github :repo "SqrtMinusOne/exwm-modeline")
|
||||||
(add-to-list 'mode-line-misc-info
|
:after (exwm)
|
||||||
'(:eval my/exwm-mode-line-info))
|
:config
|
||||||
|
(add-hook 'exwm-init-hook #'exwm-modeline-mode))
|
||||||
(defun my/exwm-mode-line-info-update ()
|
|
||||||
(setq my/exwm-mode-line-info
|
|
||||||
(concat
|
|
||||||
"["
|
|
||||||
(propertize (funcall exwm-workspace-index-map exwm-workspace-current-index)
|
|
||||||
'face
|
|
||||||
`(foreground-color . ,(doom-color 'yellow)))
|
|
||||||
"]"))
|
|
||||||
(setq my/exwm-mode-line-info-no-props (funcall exwm-workspace-index-map exwm-workspace-current-index))
|
|
||||||
(force-mode-line-update))
|
|
||||||
|
|
||||||
(add-hook 'exwm-workspace-switch-hook #'my/exwm-mode-line-info-update)
|
|
||||||
#+end_src
|
#+end_src
|
||||||
** Windows
|
** Windows
|
||||||
A bunch of functions related to managing windows in EXWM.
|
A bunch of functions related to managing windows in EXWM.
|
||||||
|
|
@ -500,35 +488,48 @@ A function to move the current workspace to another monitor.
|
||||||
(exwm-randr-refresh))
|
(exwm-randr-refresh))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Switch to the opposite monitor
|
*** Switch to the opposite monitor
|
||||||
Store the information about which workspace is available on which monitor.
|
I want to be able to switch to the opposite monitor with a keybinding. To do that, I store the list of the last workspaces I used and pick the most recent one from the other monitor.
|
||||||
|
|
||||||
#+begin_src emacs-lisp :noweb-ref exwm-monitor-config :tangle no
|
#+begin_src emacs-lisp :noweb-ref exwm-monitor-config :tangle no
|
||||||
(setq my/exwm-monitor-workspace '())
|
(setq my/exwm-last-workspaces '(1))
|
||||||
|
|
||||||
(defun my/exwm-get-current-monitor ()
|
(defun my/exwm-store-last-workspace ()
|
||||||
(if (plist-get exwm-randr-workspace-monitor-plist exwm-workspace-current-index)
|
(setq my/exwm-last-workspaces
|
||||||
1 0))
|
(seq-uniq (cons exwm-workspace-current-index
|
||||||
|
my/exwm-last-workspaces))))
|
||||||
(defun my/exwm-update-current-monitor ()
|
|
||||||
(setf (alist-get (my/exwm-get-current-monitor) my/exwm-monitor-workspace)
|
|
||||||
exwm-workspace-current-index))
|
|
||||||
|
|
||||||
(add-hook 'exwm-workspace-switch-hook
|
(add-hook 'exwm-workspace-switch-hook
|
||||||
#'my/exwm-update-current-monitor)
|
#'my/exwm-store-last-workspace)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Switch to the opposite monitor. For now, this works only for two monitors because I don't have more.
|
Switch to the opposite monitor.
|
||||||
#+begin_src emacs-lisp :noweb-ref exwm-monitor-config :tangle no
|
#+begin_src emacs-lisp :noweb-ref exwm-monitor-config :tangle no
|
||||||
(defun my/exwm-switch-to-other-monitor ()
|
(defun my/exwm-switch-to-other-monitor ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((current (my/exwm-get-current-monitor))
|
(let* ((current-monitor
|
||||||
(other (seq-some
|
(plist-get exwm-randr-workspace-output-plist
|
||||||
(lambda (m)
|
(cl-position (selected-frame)
|
||||||
(and (not (= (car m) current)) (cdr m)))
|
exwm-workspace--list)))
|
||||||
my/exwm-monitor-workspace))
|
(all-monitors
|
||||||
(focus-follows-mouse nil)
|
(seq-uniq
|
||||||
(mouse-autoselect-window nil))
|
(cons nil
|
||||||
(exwm-workspace-switch other)))
|
(cl-loop for (key value) on exwm-randr-workspace-output-plist
|
||||||
|
by 'cddr collect value))))
|
||||||
|
(other-monitor
|
||||||
|
(nth
|
||||||
|
(% (1+ (cl-position current-monitor all-monitors))
|
||||||
|
(length all-monitors))
|
||||||
|
all-monitors)))
|
||||||
|
(exwm-workspace-switch
|
||||||
|
(cl-loop for i in (append my/exwm-last-workspaces
|
||||||
|
(cl-loop for i from 0
|
||||||
|
for _ in exwm-workspace--list
|
||||||
|
collect i))
|
||||||
|
if (if other-monitor
|
||||||
|
(string-equal (plist-get exwm-randr-workspace-output-plist i)
|
||||||
|
other-monitor)
|
||||||
|
(not (plist-get exwm-randr-workspace-output-plist i)))
|
||||||
|
return i))))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Apps
|
** Apps
|
||||||
*** App shortcuts
|
*** App shortcuts
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue