summaryrefslogtreecommitdiff
path: root/users/kassouni/palette/fuzzel-palette.nix
diff options
context:
space:
mode:
Diffstat (limited to 'users/kassouni/palette/fuzzel-palette.nix')
-rw-r--r--users/kassouni/palette/fuzzel-palette.nix27
1 files changed, 27 insertions, 0 deletions
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]}"
+ '')
+ ];
+}