summaryrefslogtreecommitdiff
path: root/users/kassouni/palette/rofi-palette.nix
blob: 7418cebfcee02781620f33cd73fa6a9ec6252aec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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]}"
    '')
  ];
}