[exwm] make window switching more robust
This commit is contained in:
parent
fc5eca36a3
commit
3e406a715a
29
init.org
29
init.org
|
@ -121,18 +121,19 @@ A less repetitive way to start processes. Also enables Boon in the process buffe
|
|||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-start-app-or-switch (program &optional name exact-p &rest args)
|
||||
"If NAME is a running application, switch to its EXWM buffer.
|
||||
Otherwise, run PROGRAM with ARGS.
|
||||
|
||||
If EXACT-P is non-nil, the window title must match the name exactly."
|
||||
(defun my-start-app-or-switch (program &optional class-re title-re name &rest args)
|
||||
"Switch to EXWM buffer matching CLASS-RE or TITLE-RE, or run PROGRAM with ARGS.
|
||||
NAME is the name of the process and its buffer."
|
||||
(let* ((name (if name name program))
|
||||
(regex (if exact-p (rx-to-string `(and bos ,name eos)) name))
|
||||
(regex (or class-re title-re program))
|
||||
(buffer (seq-find
|
||||
(lambda (buffer)
|
||||
(with-current-buffer buffer
|
||||
(and exwm-title
|
||||
(string-match-p regex exwm-title))))
|
||||
(if title-re
|
||||
(and exwm-title
|
||||
(string-match-p title-re exwm-title))
|
||||
(and exwm-class-name
|
||||
(string-match-p regex exwm-class-name)))))
|
||||
(buffer-list))))
|
||||
(if buffer (switch-to-buffer buffer)
|
||||
(apply #'my-start-process program name args))))
|
||||
|
@ -1411,12 +1412,16 @@ _u_: next word ^_l_: edit lines^ _s_: next whole symbol
|
|||
("E" contrapunctus-emms-hydra/body "emms")
|
||||
|
||||
;; external
|
||||
("g" (my-start-app-or-switch "gajim" nil t) "Gajim")
|
||||
("b" (my-start-app-or-switch "/media/data/anon/ext/tor-browser_en-US/Browser/start-tor-browser" "Tor Browser")
|
||||
("g" (my-start-app-or-switch "gajim" nil "^Gajim") "Gajim")
|
||||
("b" (my-start-app-or-switch
|
||||
"/media/data/anon/ext/tor-browser_en-US/Browser/start-tor-browser"
|
||||
"^Tor Browser$")
|
||||
"Tor Browser")
|
||||
("B" (my-start-app-or-switch "/media/data/anon/ext/firefox/firefox" "firefox") "Firefox")
|
||||
("B" (my-start-app-or-switch
|
||||
"/media/data/anon/ext/firefox/firefox" "firefox")
|
||||
"Firefox")
|
||||
("k" (my-start-app-or-switch "keepassxc") "KeePassXC")
|
||||
("t" (my-start-app-or-switch "xfce4-terminal" "terminal") "terminal")
|
||||
("t" (my-start-app-or-switch "xfce4-terminal") "terminal")
|
||||
("T" (my-start-app-or-switch "transmission-gtk") "bittorrent"))
|
||||
#+END_SRC
|
||||
*** org
|
||||
|
|
Loading…
Reference in New Issue