blob: 9e3c1a2633e84d5426bbf86a8e3873ed32c5f2a8 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
{
lib,
config,
tsunamiLib,
...
}: let
inherit (tsunamiLib) scriptPath;
inherit (lib.strings) escapeShellArg;
cfg = config.tsunami.keys;
in {
options = let
tmuxKey = lib.types.strMatching "^((C|M|S)-)*(.|Enter|Escape|Tab|Up|Down|Left|Right)$";
inherit (lib) mkOption;
in {
tsunami.keys = {
leader = mkOption {
type = with lib.types;
listOf (submodule {
options = {
name = mkOption {type = str;};
key = mkOption {type = tmuxKey;};
exec = mkOption {type = str;};
};
});
};
global = mkOption {
type = with lib.types;
listOf (submodule {
options = {
key = mkOption {type = tmuxKey;};
exec = mkOption {type = str;};
};
});
};
};
};
config = {
tsunami.scripts = {
"menu" = ''
tmux display-menu \
-x "#{window_width}" -y S \
-b none \
-s "bg=#313244,fg=#9399b2" \
-S "bg=#313244" \
-H "bg=#45475a fg=#b4befe" \
"$@"
'';
"leader-menu" = let
args = lib.concatStringsSep " " (builtins.map (f: "${escapeShellArg f.name} ${f.key} ${escapeShellArg f.exec}") cfg.leader);
in ''
${scriptPath "menu"} ${args}
'';
};
tsunami.keys.global = [
{
key = "C-x";
exec = "run-shell ${scriptPath "leader-menu"}";
}
];
tsunami.confs."global-keys" = cfg.global |> builtins.map (f: "bind-key -n ${f.key} ${escapeShellArg f.exec}") |> lib.concatStringsSep "\n";
};
}
|