feat(exwm): transient -> hydra for app shortcuts

This commit is contained in:
Pavel Korytov 2021-12-04 00:08:06 +03:00
parent c6987720e9
commit bcbea86087
2 changed files with 37 additions and 23 deletions

View file

@ -114,14 +114,22 @@ _=_: Balance "
(let ((command-parts (split-string command "[ ]+"))) (let ((command-parts (split-string command "[ ]+")))
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
(transient-define-prefix my/exwm-apps () (defhydra my/exwm-apps-hydra (:color blue :hint nil)
["Apps" "
("t" "Termnial (Alacritty)" (lambda () (interactive) (my/run-in-background "alacritty"))) ^Apps^
("b" "Browser (Firefox)" (lambda () (interactive) (my/run-in-background "firefox"))) _t_: Terminal (Alacritty)
("v" "VK" (lambda () (interactive) (my/run-in-background "vk"))) _b_: Browser (Firefox)
("s" "Slack" (lambda () (interactive) (my/run-in-background "slack-wrapper"))) _v_: VK
("d" "Discord" (lambda () (interactive) (my/run-in-background "flatpak run com.discordapp.Discord"))) _s_: Slack
("q" "Quit" transient-quit-one)]) _d_: Discord
"
("t" (lambda () (interactive)
(persp-switch "term")
(my/run-in-background "alacritty")))
("b" (lambda () (interactive) (my/run-in-background "firefox")))
("v" (lambda () (interactive) (my/run-in-background "vk")))
("s" (lambda () (interactive) (my/run-in-background "slack-wrapper")))
("d" (lambda () (interactive) (my/run-in-background "flatpak run com.discordapp.Discord"))))
(defun my/exwm-lock () (defun my/exwm-lock ()
(interactive) (interactive)
@ -252,7 +260,7 @@ _=_: Balance "
;; Apps & stuff ;; Apps & stuff
(,(kbd "s-p") . ,(my/app-command "rofi -modi drun,run -show drun")) (,(kbd "s-p") . ,(my/app-command "rofi -modi drun,run -show drun"))
(,(kbd "s-;") . my/exwm-apps) (,(kbd "s-;") . my/exwm-apps-hydra/body)
(,(kbd "s--") . ,(my/app-command "rofi-pass")) (,(kbd "s--") . ,(my/app-command "rofi-pass"))
(,(kbd "s-=") . ,(my/app-command "rofimoji")) (,(kbd "s-=") . ,(my/app-command "rofimoji"))
(,(kbd "s-i") . ,(my/app-command "copyq menu")) (,(kbd "s-i") . ,(my/app-command "copyq menu"))

View file

@ -364,7 +364,7 @@ Show the current workspace in the modeline.
(add-hook 'exwm-workspace-switch-hook #'my/exwm-mode-line-info-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.
*** Moving windows *** Moving windows
My functions for managing windows. I initially wrote these to mimic the i3 behavior for my Emacs + i3 integration, but I want to try to keep them for the EXWM config as well to make the transition less painful. My functions for managing windows. I initially wrote these to mimic the i3 behavior for my Emacs + i3 integration, but I want to try to keep them for the EXWM config as well to make the transition less painful.
@ -399,7 +399,7 @@ And a function to move windows with the following behavior:
(evil-move-window dir))))) (evil-move-window dir)))))
#+end_src #+end_src
*** Resizing windows *** Resizing windows
Something like this also goes for resizing windows. I'm used to the i3 "mode" for this functionality, and this seems to be a sensible approach. A hydra so resize windows. It also mimics i3's behavior somewhat.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq my/exwm-resize-value 5) (setq my/exwm-resize-value 5)
@ -509,9 +509,7 @@ Switch to the opposite monitor. For now, this works only for two monitors becaus
#+end_src #+end_src
** Apps ** Apps
*** App shortcuts *** App shortcuts
A transient for shortcuts for the most frequent apps. A +transient+ hydra for shortcuts for the most frequent apps.
I wanted to make the interactive lambda a macro, but this doesn't seem to work the way I expect, so the code has a bit of duplication.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package transient (use-package transient
:straight t) :straight t)
@ -520,14 +518,22 @@ I wanted to make the interactive lambda a macro, but this doesn't seem to work t
(let ((command-parts (split-string command "[ ]+"))) (let ((command-parts (split-string command "[ ]+")))
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
(transient-define-prefix my/exwm-apps () (defhydra my/exwm-apps-hydra (:color blue :hint nil)
["Apps" "
("t" "Termnial (Alacritty)" (lambda () (interactive) (my/run-in-background "alacritty"))) ^Apps^
("b" "Browser (Firefox)" (lambda () (interactive) (my/run-in-background "firefox"))) _t_: Terminal (Alacritty)
("v" "VK" (lambda () (interactive) (my/run-in-background "vk"))) _b_: Browser (Firefox)
("s" "Slack" (lambda () (interactive) (my/run-in-background "slack-wrapper"))) _v_: VK
("d" "Discord" (lambda () (interactive) (my/run-in-background "flatpak run com.discordapp.Discord"))) _s_: Slack
("q" "Quit" transient-quit-one)]) _d_: Discord
"
("t" (lambda () (interactive)
(persp-switch "term")
(my/run-in-background "alacritty")))
("b" (lambda () (interactive) (my/run-in-background "firefox")))
("v" (lambda () (interactive) (my/run-in-background "vk")))
("s" (lambda () (interactive) (my/run-in-background "slack-wrapper")))
("d" (lambda () (interactive) (my/run-in-background "flatpak run com.discordapp.Discord"))))
#+end_src #+end_src
*** Locking up *** Locking up
Run i3lock. Run i3lock.
@ -618,7 +624,7 @@ And keybindings that are available in both =char-mode= and =line-mode=:
;; Apps & stuff ;; Apps & stuff
(,(kbd "s-p") . ,(my/app-command "rofi -modi drun,run -show drun")) (,(kbd "s-p") . ,(my/app-command "rofi -modi drun,run -show drun"))
(,(kbd "s-;") . my/exwm-apps) (,(kbd "s-;") . my/exwm-apps-hydra/body)
(,(kbd "s--") . ,(my/app-command "rofi-pass")) (,(kbd "s--") . ,(my/app-command "rofi-pass"))
(,(kbd "s-=") . ,(my/app-command "rofimoji")) (,(kbd "s-=") . ,(my/app-command "rofimoji"))
(,(kbd "s-i") . ,(my/app-command "copyq menu")) (,(kbd "s-i") . ,(my/app-command "copyq menu"))