diff options
| author | Alexander Kassouni <alex@kassouni.net> | 2026-09-02 21:20:10 -0700 |
|---|---|---|
| committer | Alexander Kassouni <alex@kassouni.net> | 2026-09-02 21:20:10 -0700 |
| commit | 47dde98fd2cf11ea544bb1c8d8d548ee0bda0f54 (patch) | |
| tree | fb79c45ef1c0f0016e480e06dff625cf3fc1c91a /users/kassouni/palette | |
| parent | 1c5fa1c205f2bb78f8e1179b0576f3c3578dad69 (diff) | |
some sway stuff
Diffstat (limited to 'users/kassouni/palette')
| -rw-r--r-- | users/kassouni/palette/default.nix | 26 | ||||
| -rw-r--r-- | users/kassouni/palette/fuzzel-palette.nix | 27 | ||||
| -rw-r--r-- | users/kassouni/palette/rofi-palette.nix | 24 |
3 files changed, 56 insertions, 21 deletions
diff --git a/users/kassouni/palette/default.nix b/users/kassouni/palette/default.nix index 403aa60..0600510 100644 --- a/users/kassouni/palette/default.nix +++ b/users/kassouni/palette/default.nix @@ -1,12 +1,4 @@ -{ - config, - lib, - pkgs, - ... -}: -let - cfg = config.kassouni.palette; -in +{ lib, ... }: { imports = [ ./bluetooth.nix @@ -14,6 +6,8 @@ in ./rebuild.nix ./screenshot.nix ./shutdown.nix + ./rofi-palette.nix + ./fuzzel-palette.nix ]; options.kassouni.palette.commands = lib.mkOption { @@ -37,18 +31,8 @@ in ); default = [ ]; description = '' - Entries shown in the rofi command palette. + Entries shown in the command palette. Rendered by both front ends: + `open-palette` (rofi, X11) and `open-palette-fuzzel` (fuzzel, Wayland). ''; }; - - config.home.packages = [ - (pkgs.writers.writeBashBin "open-palette" '' - set -eu - exes=(${lib.concatMapStringsSep " " (c: "${c.exe}") cfg.commands}) - idx=$(${pkgs.rofi}/bin/rofi -dmenu -i -format i -p palette <<EOF -${lib.concatMapStrings (c: "${c.icon} ${c.name}\n") cfg.commands}EOF - ) - exec "''${exes[$idx]}" - '') - ]; } diff --git a/users/kassouni/palette/fuzzel-palette.nix b/users/kassouni/palette/fuzzel-palette.nix new file mode 100644 index 0000000..d6d4774 --- /dev/null +++ b/users/kassouni/palette/fuzzel-palette.nix @@ -0,0 +1,27 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.kassouni.palette; +in +{ + # Wayland front end for the palette. `--index` is fuzzel's answer to rofi's + # `-format i`, so the same index-into-exes trick works. Unlike rofi, fuzzel + # will happily accept text that matches no row; it exits non-zero there, but + # the numeric guard keeps a surprising build of fuzzel from indexing the + # array with garbage. + home.packages = [ + (pkgs.writers.writeBashBin "open-palette-fuzzel" '' + set -eu + exes=(${lib.concatMapStringsSep " " (c: "${c.exe}") cfg.commands}) + idx=$(${pkgs.fuzzel}/bin/fuzzel --dmenu --index --prompt "palette " <<EOF +${lib.concatMapStrings (c: "${c.icon} ${c.name}\n") cfg.commands}EOF + ) + [[ $idx =~ ^[0-9]+$ ]] && [[ $idx -lt ''${#exes[@]} ]] || exit 1 + exec "''${exes[$idx]}" + '') + ]; +} diff --git a/users/kassouni/palette/rofi-palette.nix b/users/kassouni/palette/rofi-palette.nix new file mode 100644 index 0000000..7418ceb --- /dev/null +++ b/users/kassouni/palette/rofi-palette.nix @@ -0,0 +1,24 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.kassouni.palette; +in +{ + # X11 front end for the palette. `-format i` makes rofi print the row index, + # so the label shown and the executable run stay paired by position rather + # than by parsing the label back out. + home.packages = [ + (pkgs.writers.writeBashBin "open-palette" '' + set -eu + exes=(${lib.concatMapStringsSep " " (c: "${c.exe}") cfg.commands}) + idx=$(${pkgs.rofi}/bin/rofi -dmenu -i -format i -p palette <<EOF +${lib.concatMapStrings (c: "${c.icon} ${c.name}\n") cfg.commands}EOF + ) + exec "''${exes[$idx]}" + '') + ]; +} |
