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
(dashboard-setup-startup-hook))
(add-to-list 'display-buffer-alist
'("\\*launcher\\*" ;; Adjust to match your launcher's buffer name
(display-buffer-same-window)
(inhibit-same-window . nil)))
;; 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))))
;; IMPORTANT: This allows us to use our custom Emacs launchers
;; without getting the annoying second window created.
(setq display-buffer-alist
'(("^\\(\\*.*\\*\\|Dashboard\\)$"
(display-buffer-no-window)
(allow-no-window . t))))
(use-package diminish)

View File

@@ -142,17 +142,13 @@ Emacs Dashboard is an extensible startup screen showing you recent files, bookma
:config
(dashboard-setup-startup-hook))
(add-to-list 'display-buffer-alist
'("\\*launcher\\*" ;; Adjust to match your launcher's buffer name
(display-buffer-same-window)
(inhibit-same-window . nil)))
;; IMPORTANT: This allows us to use our custom Emacs launchers
;; without getting the annoying second window created.
(setq display-buffer-alist
'(("^\\(\\*.*\\*\\|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
* DIMINISH

View File

@@ -5,23 +5,18 @@
;; 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.
(defun dt/emacs-counsel-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"
(defun dt/emacs-run-launcher ()
"Launcher that works with the frame created by emacsclient."
(interactive)
(with-selected-frame
(make-frame '((name . "emacs-run-launcher")
(minibuffer . only)
(fullscreen . 0) ; no fullscreen
(undecorated . t) ; remove title bar
;;(auto-raise . t) ; focus on this frame
;;(tool-bar-lines . 0)
;;(menu-bar-lines . 0)
(internal-border-width . 10)
(width . 80)
(height . 11)))
(unwind-protect
(counsel-linux-app)
(delete-frame))))
(let ((frame (selected-frame)))
(modify-frame-parameters frame
'((undecorated . t)
(internal-border-width . 10)
(menu-bar-lines . 0)
(tool-bar-lines . 0)))
(unwind-protect
(app-launcher-run-app)
(delete-frame frame))))
;; 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.
@@ -31,7 +26,7 @@
;; create a global keyboard shortcut with the following code
;; 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"
(interactive)
(with-selected-frame
@@ -49,6 +44,21 @@
(app-launcher-run-app)
(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
(require 'json) ;; for bookmarks and 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 = [
# The essentials
Key([mod], "Return", lazy.spawn(myTerm), desc="Terminal"),
# Use 'rofi' as a run launcher.
Key([mod, "shift"], "Return", lazy.spawn("rofi -show drun -show-icons"), desc='Run Launcher'),
# Use 'rofi' as your 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], "b", lazy.hide_show_bar(position='all'), desc="Toggles the bar to show/hide"),
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'
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([], "a", lazy.spawn("dm-sounds -r"), desc='Choose ambient sound'),
Key([], "b", lazy.spawn("dm-setbg -r"), desc='Set background'),
@@ -607,25 +609,26 @@ floating_layout = layout.Floating(
float_rules=[
# Run the utility of `xprop` to see the wm class and name of an X client.
*layout.Floating.default_float_rules,
Match(wm_class="confirmreset"), # gitk
Match(wm_class="dialog"), # dialog boxes
Match(wm_class="download"), # downloads
Match(wm_class="error"), # error msgs
Match(wm_class="file_progress"), # file progress boxes
Match(wm_class='kdenlive'), # kdenlive
Match(wm_class="makebranch"), # gitk
Match(wm_class="maketag"), # gitk
Match(wm_class="notification"), # notifications
Match(wm_class='pinentry-gtk-2'), # GPG key password entry
Match(wm_class="ssh-askpass"), # ssh-askpass
Match(wm_class="toolbar"), # toolbars
Match(wm_class="Yad"), # yad boxes
Match(title="branchdialog"), # gitk
Match(title='Confirmation'), # tastyworks exit box
Match(title='Qalculate!'), # qalculate-gtk
Match(title="pinentry"), # GPG key password entry
Match(title="tastycharts"), # tastytrade pop-out charts
Match(title="tastytrade"), # tastytrade pop-out side gutter
Match(wm_class="confirmreset"), # gitk
Match(wm_class="dialog"), # dialog boxes
Match(wm_class="download"), # downloads
Match(wm_class="error"), # error msgs
Match(wm_class="file_progress"), # file progress boxes
Match(wm_class='kdenlive'), # kdenlive
Match(wm_class="makebranch"), # gitk
Match(wm_class="maketag"), # gitk
Match(wm_class="notification"), # notifications
Match(wm_class='pinentry-gtk-2'), # GPG key password entry
Match(wm_class="ssh-askpass"), # ssh-askpass
Match(wm_class="toolbar"), # toolbars
Match(wm_class="Yad"), # yad boxes
Match(title="branchdialog"), # gitk
Match(title='Confirmation'), # tastyworks exit box
Match(title="emacs-run-launcher"), # dt/emacs-run-launcher
Match(title="pinentry"), # GPG key password entry
Match(title='Qalculate!'), # qalculate-gtk
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(wm_class="tasty.javafx.launcher.LauncherFxApp"), # tastytrade settings
]

View File

@@ -61,8 +61,10 @@ def maximize_by_switching_layout(qtile):
keys = [
# The essentials
Key([mod], "Return", lazy.spawn(myTerm), desc="Terminal"),
# Use 'rofi' as a run launcher.
Key([mod, "shift"], "Return", lazy.spawn("rofi -show drun -show-icons"), desc='Run Launcher'),
# Use 'rofi' as your 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], "b", lazy.hide_show_bar(position='all'), desc="Toggles the bar to show/hide"),
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'
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([], "a", lazy.spawn("dm-sounds -r"), desc='Choose ambient sound'),
Key([], "b", lazy.spawn("dm-setbg -r"), desc='Set background'),
@@ -464,25 +466,26 @@ floating_layout = layout.Floating(
float_rules=[
# Run the utility of `xprop` to see the wm class and name of an X client.
*layout.Floating.default_float_rules,
Match(wm_class="confirmreset"), # gitk
Match(wm_class="dialog"), # dialog boxes
Match(wm_class="download"), # downloads
Match(wm_class="error"), # error msgs
Match(wm_class="file_progress"), # file progress boxes
Match(wm_class='kdenlive'), # kdenlive
Match(wm_class="makebranch"), # gitk
Match(wm_class="maketag"), # gitk
Match(wm_class="notification"), # notifications
Match(wm_class='pinentry-gtk-2'), # GPG key password entry
Match(wm_class="ssh-askpass"), # ssh-askpass
Match(wm_class="toolbar"), # toolbars
Match(wm_class="Yad"), # yad boxes
Match(title="branchdialog"), # gitk
Match(title='Confirmation'), # tastyworks exit box
Match(title='Qalculate!'), # qalculate-gtk
Match(title="pinentry"), # GPG key password entry
Match(title="tastycharts"), # tastytrade pop-out charts
Match(title="tastytrade"), # tastytrade pop-out side gutter
Match(wm_class="confirmreset"), # gitk
Match(wm_class="dialog"), # dialog boxes
Match(wm_class="download"), # downloads
Match(wm_class="error"), # error msgs
Match(wm_class="file_progress"), # file progress boxes
Match(wm_class='kdenlive'), # kdenlive
Match(wm_class="makebranch"), # gitk
Match(wm_class="maketag"), # gitk
Match(wm_class="notification"), # notifications
Match(wm_class='pinentry-gtk-2'), # GPG key password entry
Match(wm_class="ssh-askpass"), # ssh-askpass
Match(wm_class="toolbar"), # toolbars
Match(wm_class="Yad"), # yad boxes
Match(title="branchdialog"), # gitk
Match(title='Confirmation'), # tastyworks exit box
Match(title="emacs-run-launcher"), # dt/emacs-run-launcher
Match(title="pinentry"), # GPG key password entry
Match(title='Qalculate!'), # qalculate-gtk
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(wm_class="tasty.javafx.launcher.LauncherFxApp"), # tastytrade settings
]