From 5f87eb37b6bd0fe273c24f6678a99ce1f846ed06 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 21 May 2022 03:36:36 +0100 Subject: exwm: app togglers --- exwm.org | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'exwm.org') diff --git a/exwm.org b/exwm.org index 917f8ba..41adb52 100644 --- a/exwm.org +++ b/exwm.org @@ -231,7 +231,9 @@ (interactive) ,@(when ws `((jao-exwm-workspace ,ws))) (if (jao-exwm-switch-to-class/title ,class) - ,(if (stringp (car args)) (cdr args) args) + ,(cond ((equal ws 5) '(delete-other-windows)) + ((stringp (car args)) (cdr args)) + (t args)) (setq jao-exwm--current-name ,class) ,(if (stringp (car args)) `(start-process-shell-command ,(car args) @@ -241,6 +243,15 @@ " ")) args)))) + (defmacro jao-def-exwm-toggler (name ws class &rest args) + (let ((toggler (intern (format "%s*" name))) + (arg (gensym))) + `(progn (jao-def-exwm-runner ,name ,ws ,class ,@args) + (defun ,toggler (,arg) + (interactive "P") + (if (and (not ,arg) (equal exwm-class-name ,class)) + (jao-afio--goto-main) + (,name)))))) (defun jao-exwm--send-str (str) (dolist (k (string-to-list (kbd str))) @@ -278,8 +289,7 @@ (jao-def-exwm-runner jao-exwm-open-with-mupdf nil nil "mupdf" (buffer-file-name)) (jao-def-exwm-runner jao-exwm-xterm 0 nil "xterm") - (jao-def-exwm-runner jao-exwm-tidal 5 - "tidal-hifi" "tidal-hifi" delete-other-windows) + (jao-def-exwm-toggler jao-exwm-tidal 5 "tidal-hifi" "tidal-hifi") (defalias 'jao-streaming-list #'jao-exwm-tidal) (defun jao-exwm-import-screen (&optional area) @@ -413,15 +423,10 @@ #+end_src * Firefox support #+begin_src emacs-lisp - (jao-def-exwm-runner jao-exwm-firefox 5 "Firefox" "firefox") - - (defun jao-exwm-firefox-1 () - (interactive) - (jao-exwm-firefox) - (delete-other-windows)) + (jao-def-exwm-toggler jao-exwm-firefox 5 "Firefox" "firefox") (defun jao-exwm-browse-with-firefox (&rest args) - (jao-exwm-firefox-1) + (jao-exwm-firefox) (apply #'browse-url-firefox args)) (setq browse-url-secondary-browser-function #'jao-exwm-browse-with-firefox) @@ -434,12 +439,6 @@ (jao-exwm--send-str "yy") (switch-to-buffer cb)))) - (defun jao-exwm-toggle-firefox (ff) - (interactive "P") - (if (and (not ff) (equal exwm-class-name "Firefox")) - (jao-afio--goto-main) - (jao-exwm-firefox-1))) - #+end_src * Transients #+begin_src emacs-lisp @@ -512,7 +511,8 @@ ([?\s-A] . org-agenda-list) ([?\s-a] . jao-first-window) ([?\s-b] . jao-transient-org-blog) - ([?\s-e] . jao-exwm-toggle-firefox) + ([?\s-d] . jao-exwm-tidal*) + ([?\s-e] . jao-exwm-firefox*) ([?\s-m] . jao-transient-media) ;; ([?\s-O] . jao-transpose-windows) ;; ([?\s-o] . jao-other-window) -- cgit v1.2.3