Nixfiles/wm/i3like-utils.nix
traxys 9e324f0b83 gui: Split wm module out of the gui module
Allowing to use DEs on select machines
2024-08-08 21:48:57 +02:00

53 lines
1.3 KiB
Nix

{ config }:
with builtins;
let
cfg = config.wm;
addKeyIf =
cond: keybinds: newkey:
if cond then newkey // keybinds else keybinds;
keybindSolo =
keys: submod: addKeyIf submod.enable keys { "${submod.keybind}" = "exec ${submod.command}"; };
keydefs = [
cfg.printScreen
cfg.menu
cfg.exit
];
keybindingsKeydef = foldl' keybindSolo cfg.keybindings keydefs;
mod = cfg.modifier;
ws_def = cfg.workspaces.definitions;
get_ws = ws: getAttr ws ws_def;
workspaceFmt =
name:
let
inherit ((get_ws name)) key;
in
{
"${mod}+${key}" = "workspace ${name}";
"${mod}+${cfg.workspaces.moveModifier}+${key}" = "move container to workspace ${name}";
};
workspaceAssign = name: {
workspace = name;
inherit ((get_ws name)) output;
};
classAssign = name: { "${name}" = map (app: { class = "${app}"; }) (get_ws name).assign; };
in
{
mkFont = mod: {
names = [ mod.name ];
inherit (mod) style;
inherit (mod) size;
};
keybindings =
(foldl' (x: y: x // y) { } (map workspaceFmt (attrNames ws_def))) // keybindingsKeydef;
workspaceOutputAssign = map workspaceAssign (
filter (ws: (get_ws ws).output != null) (attrNames ws_def)
);
assigns = foldl' (x: y: x // y) { } (map classAssign (attrNames ws_def));
}