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 "[ ]+")))
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
(transient-define-prefix my/exwm-apps ()
["Apps"
("t" "Termnial (Alacritty)" (lambda () (interactive) (my/run-in-background "alacritty")))
("b" "Browser (Firefox)" (lambda () (interactive) (my/run-in-background "firefox")))
("v" "VK" (lambda () (interactive) (my/run-in-background "vk")))
("s" "Slack" (lambda () (interactive) (my/run-in-background "slack-wrapper")))
("d" "Discord" (lambda () (interactive) (my/run-in-background "flatpak run com.discordapp.Discord")))
("q" "Quit" transient-quit-one)])
(defhydra my/exwm-apps-hydra (:color blue :hint nil)
"
^Apps^
_t_: Terminal (Alacritty)
_b_: Browser (Firefox)
_v_: VK
_s_: Slack
_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 ()
(interactive)
@ -252,7 +260,7 @@ _=_: Balance "
;; Apps & stuff
(,(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 "rofimoji"))
(,(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)
#+end_src
** Windows
A bunch of functions related to managing windows in EXWM
A bunch of functions related to managing windows in EXWM.
*** 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.
@ -399,7 +399,7 @@ And a function to move windows with the following behavior:
(evil-move-window dir)))))
#+end_src
*** 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
(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
** Apps
*** App shortcuts
A transient 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.
A +transient+ hydra for shortcuts for the most frequent apps.
#+begin_src emacs-lisp
(use-package transient
: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 "[ ]+")))
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
(transient-define-prefix my/exwm-apps ()
["Apps"
("t" "Termnial (Alacritty)" (lambda () (interactive) (my/run-in-background "alacritty")))
("b" "Browser (Firefox)" (lambda () (interactive) (my/run-in-background "firefox")))
("v" "VK" (lambda () (interactive) (my/run-in-background "vk")))
("s" "Slack" (lambda () (interactive) (my/run-in-background "slack-wrapper")))
("d" "Discord" (lambda () (interactive) (my/run-in-background "flatpak run com.discordapp.Discord")))
("q" "Quit" transient-quit-one)])
(defhydra my/exwm-apps-hydra (:color blue :hint nil)
"
^Apps^
_t_: Terminal (Alacritty)
_b_: Browser (Firefox)
_v_: VK
_s_: Slack
_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
*** Locking up
Run i3lock.
@ -618,7 +624,7 @@ And keybindings that are available in both =char-mode= and =line-mode=:
;; Apps & stuff
(,(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 "rofimoji"))
(,(kbd "s-i") . ,(my/app-command "copyq menu"))