76 lines
2.1 KiB
Nix
76 lines
2.1 KiB
Nix
{ lib, util, ... }:
|
|
{
|
|
checks = [
|
|
{
|
|
assertion = util.registry.predicates.uniquePerHost (entry: entry.value.keys);
|
|
message = "Desktop keybinds must use unique key chords per host.";
|
|
}
|
|
{
|
|
assertion =
|
|
entries:
|
|
lib.all (
|
|
entry:
|
|
(entry.value.action.kind == "exec" && entry.value.action.command != null)
|
|
|| (
|
|
entry.value.action.kind == "focus"
|
|
&& lib.xor (entry.value.action.direction != null) (entry.value.action.workspace != null)
|
|
)
|
|
) entries;
|
|
message = "Desktop keybind actions must set the fields their kind requires.";
|
|
}
|
|
];
|
|
|
|
type = lib.types.submodule {
|
|
options = {
|
|
keys = lib.mkOption {
|
|
description = "Sets the key chord for this desktop keybind.";
|
|
type = lib.types.str;
|
|
example = "SUPER + Return";
|
|
};
|
|
|
|
action = lib.mkOption {
|
|
description = "Declares the action this keybind runs.";
|
|
type = lib.types.submodule {
|
|
options = {
|
|
kind = lib.mkOption {
|
|
description = "Selects the keybind action kind.";
|
|
type = lib.types.enum [
|
|
"exec"
|
|
"focus"
|
|
];
|
|
};
|
|
|
|
command = lib.mkOption {
|
|
description = "Command executed by an exec keybind.";
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
example = "ghostty";
|
|
};
|
|
|
|
direction = lib.mkOption {
|
|
description = "Direction focused by a focus keybind.";
|
|
type = lib.types.nullOr (
|
|
lib.types.enum [
|
|
"down"
|
|
"left"
|
|
"right"
|
|
"up"
|
|
]
|
|
);
|
|
default = null;
|
|
example = "left";
|
|
};
|
|
|
|
workspace = lib.mkOption {
|
|
description = "Workspace focused by a focus keybind.";
|
|
type = lib.types.nullOr lib.types.int;
|
|
default = null;
|
|
example = 1;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|