feat(menu): adopt rofi plugins for calc, files, emoji
Replace the hand-rolled calc/files modules with purpose-built rofi modi (via programs.rofi.plugins) and add an emoji picker — all themed through the same .rasi as every other modi: - calc -> rofi-calc: live results as you type via libqalculate directly, which also dodges the qalc CLI's "15% of 200" -> rem(15, 1 B) misparse. Enter copies; the menu persists to chain calculations. Drops the libqalculate (qalc CLI) dependency. - files -> rofi-file-browser-extended: live directory navigation + xdg-open, replacing the flat 50k-cap `fd` dump of $HOME. yazi (SUPER+E) stays the power browser; `fd` already ships via shell.nix. - emoji -> rofi-emoji (new module): glyph picker, copies through the plugin's Wayland clipboard adapter. Bound to SUPER+CTRL+E in keybinds.nix (so it lands in the SUPER+? cheatsheet too). rofi 2.0 rebuilds cleanly with all three plugin .so (ABI-matched, same nixpkgs). README roadmap updated: calc rework marked shipped, with a follow-up item for the script-based plugins (network/secrets/audio). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,8 @@
|
||||
{ mods = "$mod CTRL"; key = "V"; action = "exec, nomarchy-menu clipboard"; desc = "Clipboard history"; }
|
||||
{ mods = "$mod CTRL"; key = "C"; action = "exec, nomarchy-menu calc"; desc = "Calculator"; }
|
||||
{ mods = "$mod CTRL"; key = "W"; action = "exec, nomarchy-menu web"; desc = "Web search"; }
|
||||
{ mods = "$mod CTRL"; key = "F"; action = "exec, nomarchy-menu files"; desc = "File search"; }
|
||||
{ mods = "$mod CTRL"; key = "F"; action = "exec, nomarchy-menu files"; desc = "File browser"; }
|
||||
{ mods = "$mod CTRL"; key = "E"; action = "exec, nomarchy-menu emoji"; desc = "Emoji picker"; }
|
||||
{ mods = "$mod CTRL"; key = "N"; action = "exec, nomarchy-menu network"; desc = "Network (nmtui)"; }
|
||||
{ mods = "$mod CTRL"; key = "B"; action = "exec, nomarchy-menu bluetooth"; desc = "Bluetooth"; }
|
||||
{ mods = "$mod CTRL"; key = "S"; action = "exec, nomarchy-menu capture"; desc = "Screenshot / capture"; }
|
||||
|
||||
@@ -100,22 +100,27 @@ let
|
||||
printf '%s' "$sel" | cliphist decode | wl-copy ;;
|
||||
|
||||
calc)
|
||||
expr=$(rofi -dmenu -p "= " < /dev/null) || exit 0
|
||||
[ -n "$expr" ] || exit 0
|
||||
result=$(qalc -t -- "$expr" 2>&1 | tail -n 1)
|
||||
choice=$(printf '%s\n' " Copy result" " New calculation" \
|
||||
| rofi -dmenu -p "= " -mesg "$expr = $result") || exit 0
|
||||
case "$choice" in
|
||||
*Copy*) printf '%s' "$result" | wl-copy ;;
|
||||
*New*) exec "$0" calc ;;
|
||||
esac ;;
|
||||
# Live calculator (rofi-calc): re-evaluates every keystroke via
|
||||
# libqalculate — which dodges the qalc CLI's "15% of 200" misparse —
|
||||
# with the answer as the top entry. Enter copies the result; the
|
||||
# menu stays open to chain calculations (Esc closes).
|
||||
exec rofi -show calc -modi calc -no-show-match -no-sort \
|
||||
-calc-command "echo -n '{result}' | wl-copy" ;;
|
||||
|
||||
files)
|
||||
sel=$(fd . "$HOME" --type f --hidden --exclude .git --exclude .cache 2>/dev/null \
|
||||
| head -n 50000 \
|
||||
| sed "s|^$HOME/||" \
|
||||
| rofi -dmenu -p file) || exit 0
|
||||
[ -n "$sel" ] && exec xdg-open "$HOME/$sel" ;;
|
||||
# Live file browser (rofi-file-browser-extended): navigate into
|
||||
# directories, go up with Backspace, toggle hidden files with the
|
||||
# rofi custom key, and open the selection with xdg-open. Starts in
|
||||
# $HOME. The keyboard-heavy TUI flagship for real work is yazi
|
||||
# (SUPER+E); this is the quick launcher path.
|
||||
exec rofi -show file-browser-extended -modi file-browser-extended \
|
||||
-file-browser-dir "$HOME" -file-browser-cmd xdg-open ;;
|
||||
|
||||
emoji)
|
||||
# Emoji / symbol picker (rofi-emoji). The default action copies the
|
||||
# glyph to the clipboard through the plugin's Wayland adapter
|
||||
# (wl-copy); the alternate action types it into the focused window.
|
||||
exec rofi -show emoji -modi emoji ;;
|
||||
|
||||
web)
|
||||
q=$(rofi -dmenu -p search < /dev/null) || exit 0
|
||||
@@ -168,6 +173,7 @@ let
|
||||
" Clipboard"
|
||||
" Calculator"
|
||||
" Files"
|
||||
" Emoji"
|
||||
" Web search"
|
||||
" Network"
|
||||
" Bluetooth"
|
||||
@@ -190,6 +196,7 @@ let
|
||||
*Clipboard*) exec "$0" clipboard ;;
|
||||
*Calc*) exec "$0" calc ;;
|
||||
*Files*) exec "$0" files ;;
|
||||
*Emoji*) exec "$0" emoji ;;
|
||||
*Web*) exec "$0" web ;;
|
||||
*Network*) exec "$0" network ;;
|
||||
*Bluetooth*) exec "$0" bluetooth ;;
|
||||
@@ -201,7 +208,7 @@ let
|
||||
esac ;;
|
||||
|
||||
*)
|
||||
echo "usage: nomarchy-menu [power|power-profile|theme|clipboard|calc|files|web|network|bluetooth|capture|keybinds|ask]" >&2
|
||||
echo "usage: nomarchy-menu [power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|capture|keybinds|ask]" >&2
|
||||
exit 64 ;;
|
||||
esac
|
||||
'';
|
||||
@@ -210,9 +217,7 @@ in
|
||||
config = lib.mkIf cfg.rofi.enable {
|
||||
home.packages = [
|
||||
nomarchy-menu
|
||||
pkgs.libqalculate # qalc, the calc module's engine
|
||||
pkgs.fd # files module
|
||||
pkgs.xdg-utils # xdg-open for files/web
|
||||
pkgs.xdg-utils # xdg-open for the web + file-browser modules
|
||||
pkgs.nodejs # npx, for the Ask Claude module (claude-code from npm)
|
||||
];
|
||||
|
||||
@@ -221,6 +226,12 @@ in
|
||||
terminal = cfg.terminal;
|
||||
font = "${t.fonts.ui} 12";
|
||||
|
||||
# Native rofi modi backing three menu modules: calc (live, via
|
||||
# libqalculate — no qalc CLI needed), emoji (glyph picker, copies via
|
||||
# its bundled Wayland adapter), file-browser (live navigation). All
|
||||
# render through the generated/whole-swap theme like every other modi.
|
||||
plugins = [ pkgs.rofi-calc pkgs.rofi-emoji pkgs.rofi-file-browser ];
|
||||
|
||||
extraConfig = {
|
||||
modi = "drun,run";
|
||||
show-icons = true; # app icons via the theme's icon set
|
||||
|
||||
Reference in New Issue
Block a user