8.5 KiB
dmenu/rofi Utilities — README
- Table of Contents
- Requirements
- Terminal selection (st, alacritty, kitty, etc.)
- Installation & files
- 1)
bookmarks-<menu>.sh - 2)
repos-<menu>.sh - 3)
tmux-<menu>.sh(“sessionizer”) - dmenu vs rofi (flags & examples)
- Optional: desktop entries & keybinds
- Troubleshooting
This repo contains three tiny scripts (each with a dmenu and a rofi variant):
bookmarks-<menu>.sh: quick launcher for personal/work bookmarksrepos-<menu>.sh: pick a repo directory and attach/create atmuxsession in ittmux-<menu>.sh: “sessionizer” for creating/switchingtmuxsessions
Throughout, you can specify your terminal as needed. See #terminal.
Table of Contents TOC_2
Requirements
- POSIX shell (/bin/sh)
tmux(forrepos-*andtmux-*)- One of:
dmenuorrofi - A terminal emulator (e.g.,
st,alacritty,kitty) - Optional:
firefox,brave(orbrave-browser),xdg-openfor bookmarks
Terminal selection (st, alacritty, kitty, etc.) terminal
All scripts are written to allow specifying your terminal. If a script hard-codes st in the example below, simply:
-
Set an environment variable before launching, e.g.:
export TERMINAL="alacritty" -
Or change the
terminalvariable near the top of the script:terminal="${TERMINAL:-st}" # prefer $TERMINAL, else use st
Anywhere you see pkill -x st or exec st -e … you can safely swap st for your terminal. If your terminal supports -e differently, adjust accordingly (e.g., Kitty: kitty tmux …; Alacritty: alacritty -e tmux …).
Installation & files installation
- Put the scripts somewhere on your
$PATH, e.g.~/bin. -
Make them executable:
chmod +x ~/bin/bookmarks-dmenu.sh \ ~/bin/bookmarks-rofi.sh \ ~/bin/repos-dmenu.sh \ ~/bin/repos-rofi.sh \ ~/bin/tmux-dmenu.sh \ ~/bin/tmux-rofi.sh -
For bookmarks, the first run will create example files if missing:
~/.config/bookmarks/personal.txt~/.config/bookmarks/work.txt
1) bookmarks-<menu>.sh
Quickly search and open bookmarks from personal and work lists. The script:
- Aggregates lines from personal/work files
- Normalizes “display :: target” lines (or raw URLs)
- Lets you pick from a fuzzy-ish menu
- Chooses a browser based on the tag (
personal→ Firefox,work→ Brave); falls back toxdg-open
Bookmark file format
Each line is one entry. Blank lines or lines beginning with # are ignored.
-
With display:
Some Site :: https://example.com/page
-
Raw URL (display = URL):
https://news.ycombinator.com
The script emits entries like:
[personal] Some Site :: https://example.com/page [work] Docs :: https://nixos.org/manual/
Configuration
Environment variables (override as needed):
PERS_FILE="$HOME/.config/bookmarks/personal.txt"
WORK_FILE="$HOME/.config/bookmarks/work.txt"
# Browsers (detected automatically if installed)
FIREFOX="$(command -v firefox || true)"
BRAVE="$(command -v brave || command -v brave-browser || true)"
FALLBACK="$(command -v xdg-open || echo firefox)"
You can change which browser opens which tag by editing the case "$tag" in … section.
Usage
-
dmenu:
bookmarks-dmenu.sh -
rofi:
bookmarks-rofi.sh
Pick an entry and it opens in the appropriate browser. If a scheme is missing, https:// is assumed.
2) repos-<menu>.sh
Presents a list of directories under ~/repos and opens a dedicated tmux session per project. It enforces a “single terminal” workflow by killing any existing instance of your chosen terminal, then starting a clean one attached to the chosen session.
Configuration
-
Repo root:
REPO_ROOT="$HOME/repos" -
Terminal (see Terminal selection):
terminal="${TERMINAL:-st}" - Menu prompt & layout are set via the menu’s flags (see dmenu vs rofi).
Usage
-
dmenu:
repos-dmenu.sh -
rofi:
repos-rofi.sh
Flow:
- Pick a directory from
~/repos - Script kills any existing
$terminal(optional “one terminal at a time” behavior) - Launches
tmux new-session -As "<repo-name>" -c "<repo-dir>"inside$terminal
3) tmux-<menu>.sh (“sessionizer”)
Lists existing tmux sessions, plus a “Create new session…” option. Works both inside and outside tmux.
Configuration :tmux-config:
-
Terminal (outside-tmux attach/create path):
terminal="${TERMINAL:-st}" - Menu binary & options are configurable (see dmenu vs rofi).
Usage
-
dmenu:
tmux-dmenu.sh -
rofi:
tmux-rofi.sh
Behavior:
-
Inside
tmux:- “Create new …” → creates a detached session if it doesn’t exist, then switches client to it
- Selecting an existing session just switches the client
-
Outside
tmux:- Kills existing
${terminal}(optional “one terminal” behavior) - “Create new …” → starts
${terminal} -e tmux new-session -s "<name>" - Existing session →
${terminal} -e tmux attach -t "<name>"
- Kills existing
dmenu vs rofi (flags & examples)
Both variants do the same thing; only the menu program/flags differ.
-
dmenu example:
dmenu -i -vi -c -bw 3 -W 900 -l 30 -h 40 -F -fn 'JetBrainsMono Nerd Font:size=16' -p 'Bookmarks:' -
rofi equivalent (
rofi -dmenumode):rofi -dmenu -i -p 'Bookmarks:' -theme-str 'listview { lines: 30; }' \ -font 'JetBrainsMono Nerd Font 16'
Notes:
-l 30(dmenu “lines”) → use a rofi theme or-theme-strto set visible rows- Font names are similar; for rofi, omit the colon syntax
- Centering in rofi is controlled by theme; you can ship a
.rasior use-theme-str - If you want near-identical looks, create a tiny
.rasitheme and point both rofi variants at it
Optional: desktop entries & keybinds
Desktop entries
Create ~/.local/share/applications/bookmarks.desktop:
[Desktop Entry]
Type=Application
Name=Bookmarks (dmenu)
Exec=/home/tony/bin/bookmarks-dmenu.sh
Terminal=false
Categories=Utility;
Do the same for repos-* and tmux-*.
Keybinds
-
dwm (example):
{ MODKEY, XK_b, spawn, SHCMD("bookmarks-dmenu.sh") }, { MODKEY, XK_p, spawn, SHCMD("repos-dmenu.sh") }, { MODKEY|ShiftMask, XK_p, spawn, SHCMD("tmux-dmenu.sh") }, -
qtile (example):
Key([mod], "b", lazy.spawn("bookmarks-rofi.sh")), Key([mod], "p", lazy.spawn("repos-rofi.sh")), Key([mod, "shift"], "p", lazy.spawn("tmux-rofi.sh")),
Troubleshooting
- “No
tmuxfound”: installtmuxand ensure it’s on$PATH - “Menu not found”: install either
dmenuorrofi(match the script you’re calling) -
Terminal doesn’t open:
- Verify your
TERMINALsupports-ethe way you invoke it - Replace
pkill -x stwith your terminal name or remove the “one terminal” behavior
- Verify your
-
Bookmarks not opening in the desired browser:
- Edit the
case "$tag" in …block (e.g., use Firefox for both, or flip them) - Ensure
firefox/braveresolve viacommand -v …; otherwise the script falls back toxdg-open
- Edit the
-
Rofi layout looks cramped:
- Use a small
.rasitheme or pass-theme-strto adjust list rows, padding, and centering
- Use a small
That’s it. Each script is intentionally small and easy to modify—tweak fonts, prompts, or behavior to match your setup. Adjust your terminal as needed via TERMINAL or the terminal variable near the top of each script.