From bcbea86087c7103de1780ba081aa251313abb327 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Sat, 4 Dec 2021 00:08:06 +0300 Subject: [PATCH] feat(exwm): transient -> hydra for app shortcuts --- .emacs.d/desktop.el | 26 +++++++++++++++++--------- Desktop.org | 34 ++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.emacs.d/desktop.el b/.emacs.d/desktop.el index 3df87da..341b620 100644 --- a/.emacs.d/desktop.el +++ b/.emacs.d/desktop.el @@ -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")) diff --git a/Desktop.org b/Desktop.org index 112609b..2772bfa 100644 --- a/Desktop.org +++ b/Desktop.org @@ -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"))