Experimenting with using Emacs as a Rofi replacement; not working correctly--YET!

This commit is contained in:
Derek Taylor
2026-01-01 18:47:59 -06:00
parent 42dd1caeca
commit b316fddf3e
5 changed files with 89 additions and 82 deletions

View File

@@ -51,17 +51,12 @@
:config :config
(dashboard-setup-startup-hook)) (dashboard-setup-startup-hook))
(add-to-list 'display-buffer-alist ;; IMPORTANT: This allows us to use our custom Emacs launchers
'("\\*launcher\\*" ;; Adjust to match your launcher's buffer name ;; without getting the annoying second window created.
(display-buffer-same-window) (setq display-buffer-alist
(inhibit-same-window . nil))) '(("^\\(\\*.*\\*\\|Dashboard\\)$"
(display-buffer-no-window)
;; Force the frame to strictly have one window (allow-no-window . t))))
(add-hook 'server-after-make-frame-hook
(lambda ()
(when (equal (frame-parameter nil 'name) "launcher")
(set-window-dedicated-p (selected-window) t)
(delete-other-windows))))
(use-package diminish) (use-package diminish)

View File

@@ -142,17 +142,13 @@ Emacs Dashboard is an extensible startup screen showing you recent files, bookma
:config :config
(dashboard-setup-startup-hook)) (dashboard-setup-startup-hook))
(add-to-list 'display-buffer-alist ;; IMPORTANT: This allows us to use our custom Emacs launchers
'("\\*launcher\\*" ;; Adjust to match your launcher's buffer name ;; without getting the annoying second window created.
(display-buffer-same-window) (setq display-buffer-alist
(inhibit-same-window . nil))) '(("^\\(\\*.*\\*\\|Dashboard\\)$"
(display-buffer-no-window)
(allow-no-window . t))))
;; Force the frame to strictly have one window
(add-hook 'server-after-make-frame-hook
(lambda ()
(when (equal (frame-parameter nil 'name) "launcher")
(set-window-dedicated-p (selected-window) t)
(delete-other-windows))))
#+end_src #+end_src
* DIMINISH * DIMINISH

View File

@@ -5,23 +5,18 @@
;; Counsel-Linux-App ;; Counsel-Linux-App
;; Since we have counsel installed, we can use 'counsel-linux-app' to launch our Linux apps. It list the apps by their executable command, so it's kind of tricky to use. ;; Since we have counsel installed, we can use 'counsel-linux-app' to launch our Linux apps. It list the apps by their executable command, so it's kind of tricky to use.
(defun dt/emacs-counsel-launcher () (defun dt/emacs-run-launcher ()
"Create and select a frame called emacs-counsel-launcher which consists only of a minibuffer and has specific dimensions. Runs counsel-linux-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" "Launcher that works with the frame created by emacsclient."
(interactive) (interactive)
(with-selected-frame (let ((frame (selected-frame)))
(make-frame '((name . "emacs-run-launcher") (modify-frame-parameters frame
(minibuffer . only) '((undecorated . t)
(fullscreen . 0) ; no fullscreen (internal-border-width . 10)
(undecorated . t) ; remove title bar (menu-bar-lines . 0)
;;(auto-raise . t) ; focus on this frame (tool-bar-lines . 0)))
;;(tool-bar-lines . 0) (unwind-protect
;;(menu-bar-lines . 0) (app-launcher-run-app)
(internal-border-width . 10) (delete-frame frame))))
(width . 80)
(height . 11)))
(unwind-protect
(counsel-linux-app)
(delete-frame))))
;; App-Launcher ;; App-Launcher
;; The 'app-launcher' is a better run launcher since it reads the desktop applications on your system and you can search them by their names as defined in their desktop file. This means that sometimes you have to search for a generic term rather than the actual binary command of the program. ;; The 'app-launcher' is a better run launcher since it reads the desktop applications on your system and you can search them by their names as defined in their desktop file. This means that sometimes you have to search for a generic term rather than the actual binary command of the program.
@@ -31,7 +26,7 @@
;; create a global keyboard shortcut with the following code ;; create a global keyboard shortcut with the following code
;; emacsclient -cF "((visibility . nil))" -e "(emacs-run-launcher)" ;; emacsclient -cF "((visibility . nil))" -e "(emacs-run-launcher)"
(defun dt/emacs-run-launcher () (defun dt/emacs-run-launcher-old ()
"Create and select a frame called emacs-run-launcher which consists only of a minibuffer and has specific dimensions. Runs app-launcher-run-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" "Create and select a frame called emacs-run-launcher which consists only of a minibuffer and has specific dimensions. Runs app-launcher-run-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited"
(interactive) (interactive)
(with-selected-frame (with-selected-frame
@@ -49,6 +44,21 @@
(app-launcher-run-app) (app-launcher-run-app)
(delete-frame)))) (delete-frame))))
(defun dt/emacs-run-launcher ()
"Launcher that works with the frame created by emacsclient."
(interactive)
(let ((frame (selected-frame)))
(modify-frame-parameters frame
'((undecorated . t)
(width . 80)
(height . 11)
(internal-border-width . 10)
(menu-bar-lines . 0)
(tool-bar-lines . 0)))
(unwind-protect
(app-launcher-run-app)
(delete-frame frame))))
;; NEW LAUNCHERS ;; NEW LAUNCHERS
(require 'json) ;; for bookmarks and screenshots (require 'json) ;; for bookmarks and screenshots
(require 'cl-lib) ;; for screenshots (require 'cl-lib) ;; for screenshots

View File

@@ -137,8 +137,10 @@ A list of available commands that can be bound to keys can be found at: https://
keys = [ keys = [
# The essentials # The essentials
Key([mod], "Return", lazy.spawn(myTerm), desc="Terminal"), Key([mod], "Return", lazy.spawn(myTerm), desc="Terminal"),
# Use 'rofi' as a run launcher. # Use 'rofi' as your run launcher.
Key([mod, "shift"], "Return", lazy.spawn("rofi -show drun -show-icons"), desc='Run Launcher'), # Key([mod, "shift"], "Return", lazy.spawn("rofi -show drun -show-icons"), desc='Run Launcher'),
# Use 'emacs' as your run launcher
Key([mod, "shift"], "Return", lazy.spawn('emacsclient -ce "(dt/emacs-run-launcher)" -F "((name . \\"emacs-run-launcher\\")(minibuffer . only)(width . 80)(height . 11))"'), desc='Run Launcher'),
Key([mod], "w", lazy.spawn(myBrowser), desc='Web browser'), Key([mod], "w", lazy.spawn(myBrowser), desc='Web browser'),
Key([mod], "b", lazy.hide_show_bar(position='all'), desc="Toggles the bar to show/hide"), Key([mod], "b", lazy.hide_show_bar(position='all'), desc="Toggles the bar to show/hide"),
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"), Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
@@ -236,7 +238,7 @@ keys = [
]), ]),
# Dmenu/rofi scripts launched using the key chord SUPER+p followed by 'key' # Dmenu/rofi scripts launched using the key chord SUPER+p followed by 'key'
KeyChord([mod], "p", [ KeyChord([mod], "p", [
Key([], "Return", lazy.spawn("emacsclient -cF \"(visibility . nil)\" -e \"(dt/emacs-command-launcher)\""), desc='Emacs command launcher'), Key([], "Return", lazy.spawn('emacsclient -cF "((visibility . nil))" -e "(dt/emacs-command-launcher)"'), desc='Emacs command launcher'),
Key([], "h", lazy.spawn("dm-hub -r"), desc='List all dmscripts'), Key([], "h", lazy.spawn("dm-hub -r"), desc='List all dmscripts'),
Key([], "a", lazy.spawn("dm-sounds -r"), desc='Choose ambient sound'), Key([], "a", lazy.spawn("dm-sounds -r"), desc='Choose ambient sound'),
Key([], "b", lazy.spawn("dm-setbg -r"), desc='Set background'), Key([], "b", lazy.spawn("dm-setbg -r"), desc='Set background'),
@@ -607,25 +609,26 @@ floating_layout = layout.Floating(
float_rules=[ float_rules=[
# Run the utility of `xprop` to see the wm class and name of an X client. # Run the utility of `xprop` to see the wm class and name of an X client.
*layout.Floating.default_float_rules, *layout.Floating.default_float_rules,
Match(wm_class="confirmreset"), # gitk Match(wm_class="confirmreset"), # gitk
Match(wm_class="dialog"), # dialog boxes Match(wm_class="dialog"), # dialog boxes
Match(wm_class="download"), # downloads Match(wm_class="download"), # downloads
Match(wm_class="error"), # error msgs Match(wm_class="error"), # error msgs
Match(wm_class="file_progress"), # file progress boxes Match(wm_class="file_progress"), # file progress boxes
Match(wm_class='kdenlive'), # kdenlive Match(wm_class='kdenlive'), # kdenlive
Match(wm_class="makebranch"), # gitk Match(wm_class="makebranch"), # gitk
Match(wm_class="maketag"), # gitk Match(wm_class="maketag"), # gitk
Match(wm_class="notification"), # notifications Match(wm_class="notification"), # notifications
Match(wm_class='pinentry-gtk-2'), # GPG key password entry Match(wm_class='pinentry-gtk-2'), # GPG key password entry
Match(wm_class="ssh-askpass"), # ssh-askpass Match(wm_class="ssh-askpass"), # ssh-askpass
Match(wm_class="toolbar"), # toolbars Match(wm_class="toolbar"), # toolbars
Match(wm_class="Yad"), # yad boxes Match(wm_class="Yad"), # yad boxes
Match(title="branchdialog"), # gitk Match(title="branchdialog"), # gitk
Match(title='Confirmation'), # tastyworks exit box Match(title='Confirmation'), # tastyworks exit box
Match(title='Qalculate!'), # qalculate-gtk Match(title="emacs-run-launcher"), # dt/emacs-run-launcher
Match(title="pinentry"), # GPG key password entry Match(title="pinentry"), # GPG key password entry
Match(title="tastycharts"), # tastytrade pop-out charts Match(title='Qalculate!'), # qalculate-gtk
Match(title="tastytrade"), # tastytrade pop-out side gutter Match(title="tastycharts"), # tastytrade pop-out charts
Match(title="tastytrade"), # tastytrade pop-out side gutter
Match(title="tastytrade - Portfolio Report"), # tastytrade pop-out allocation Match(title="tastytrade - Portfolio Report"), # tastytrade pop-out allocation
Match(wm_class="tasty.javafx.launcher.LauncherFxApp"), # tastytrade settings Match(wm_class="tasty.javafx.launcher.LauncherFxApp"), # tastytrade settings
] ]

View File

@@ -61,8 +61,10 @@ def maximize_by_switching_layout(qtile):
keys = [ keys = [
# The essentials # The essentials
Key([mod], "Return", lazy.spawn(myTerm), desc="Terminal"), Key([mod], "Return", lazy.spawn(myTerm), desc="Terminal"),
# Use 'rofi' as a run launcher. # Use 'rofi' as your run launcher.
Key([mod, "shift"], "Return", lazy.spawn("rofi -show drun -show-icons"), desc='Run Launcher'), # Key([mod, "shift"], "Return", lazy.spawn("rofi -show drun -show-icons"), desc='Run Launcher'),
# Use 'emacs' as your run launcher
Key([mod, "shift"], "Return", lazy.spawn('emacsclient -ce "(dt/emacs-run-launcher)" -F "((name . \\"emacs-run-launcher\\")(minibuffer . only)(width . 80)(height . 11))"'), desc='Run Launcher'),
Key([mod], "w", lazy.spawn(myBrowser), desc='Web browser'), Key([mod], "w", lazy.spawn(myBrowser), desc='Web browser'),
Key([mod], "b", lazy.hide_show_bar(position='all'), desc="Toggles the bar to show/hide"), Key([mod], "b", lazy.hide_show_bar(position='all'), desc="Toggles the bar to show/hide"),
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"), Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
@@ -160,7 +162,7 @@ keys = [
]), ]),
# Dmenu/rofi scripts launched using the key chord SUPER+p followed by 'key' # Dmenu/rofi scripts launched using the key chord SUPER+p followed by 'key'
KeyChord([mod], "p", [ KeyChord([mod], "p", [
Key([], "Return", lazy.spawn("emacsclient -cF \"(visibility . nil)\" -e \"(dt/emacs-command-launcher)\""), desc='Emacs command launcher'), Key([], "Return", lazy.spawn('emacsclient -cF "((visibility . nil))" -e "(dt/emacs-command-launcher)"'), desc='Emacs command launcher'),
Key([], "h", lazy.spawn("dm-hub -r"), desc='List all dmscripts'), Key([], "h", lazy.spawn("dm-hub -r"), desc='List all dmscripts'),
Key([], "a", lazy.spawn("dm-sounds -r"), desc='Choose ambient sound'), Key([], "a", lazy.spawn("dm-sounds -r"), desc='Choose ambient sound'),
Key([], "b", lazy.spawn("dm-setbg -r"), desc='Set background'), Key([], "b", lazy.spawn("dm-setbg -r"), desc='Set background'),
@@ -464,25 +466,26 @@ floating_layout = layout.Floating(
float_rules=[ float_rules=[
# Run the utility of `xprop` to see the wm class and name of an X client. # Run the utility of `xprop` to see the wm class and name of an X client.
*layout.Floating.default_float_rules, *layout.Floating.default_float_rules,
Match(wm_class="confirmreset"), # gitk Match(wm_class="confirmreset"), # gitk
Match(wm_class="dialog"), # dialog boxes Match(wm_class="dialog"), # dialog boxes
Match(wm_class="download"), # downloads Match(wm_class="download"), # downloads
Match(wm_class="error"), # error msgs Match(wm_class="error"), # error msgs
Match(wm_class="file_progress"), # file progress boxes Match(wm_class="file_progress"), # file progress boxes
Match(wm_class='kdenlive'), # kdenlive Match(wm_class='kdenlive'), # kdenlive
Match(wm_class="makebranch"), # gitk Match(wm_class="makebranch"), # gitk
Match(wm_class="maketag"), # gitk Match(wm_class="maketag"), # gitk
Match(wm_class="notification"), # notifications Match(wm_class="notification"), # notifications
Match(wm_class='pinentry-gtk-2'), # GPG key password entry Match(wm_class='pinentry-gtk-2'), # GPG key password entry
Match(wm_class="ssh-askpass"), # ssh-askpass Match(wm_class="ssh-askpass"), # ssh-askpass
Match(wm_class="toolbar"), # toolbars Match(wm_class="toolbar"), # toolbars
Match(wm_class="Yad"), # yad boxes Match(wm_class="Yad"), # yad boxes
Match(title="branchdialog"), # gitk Match(title="branchdialog"), # gitk
Match(title='Confirmation'), # tastyworks exit box Match(title='Confirmation'), # tastyworks exit box
Match(title='Qalculate!'), # qalculate-gtk Match(title="emacs-run-launcher"), # dt/emacs-run-launcher
Match(title="pinentry"), # GPG key password entry Match(title="pinentry"), # GPG key password entry
Match(title="tastycharts"), # tastytrade pop-out charts Match(title='Qalculate!'), # qalculate-gtk
Match(title="tastytrade"), # tastytrade pop-out side gutter Match(title="tastycharts"), # tastytrade pop-out charts
Match(title="tastytrade"), # tastytrade pop-out side gutter
Match(title="tastytrade - Portfolio Report"), # tastytrade pop-out allocation Match(title="tastytrade - Portfolio Report"), # tastytrade pop-out allocation
Match(wm_class="tasty.javafx.launcher.LauncherFxApp"), # tastytrade settings Match(wm_class="tasty.javafx.launcher.LauncherFxApp"), # tastytrade settings
] ]