home/wm: simplify xmonad project settings

This commit is contained in:
Dmitriy Pleshevskiy 2024-02-27 19:08:53 +03:00
parent b02bcdd82d
commit 6f7991184d
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
2 changed files with 28 additions and 5 deletions

View file

@ -9,18 +9,41 @@ let
name = mkOption {
type = types.str;
};
startHook = mkOption {
type = types.lines;
workdir = mkOption {
type = types.str;
};
windowCount = mkOption {
type = types.ints.positive;
default = 1;
};
terminalCommands = mkOption {
type = types.listOf types.str;
default = [ ];
};
spawnPrograms = mkOption {
type = types.listOf types.str;
default = [ ];
};
};
};
mkXmonadProject = { name, startHook }:
mkXmonadProjectSpawnProgram = program:
"spawn \"${program}\"";
mkXmonadProjectTerminalCommand = command:
"spawn $ terminal' workdir $ Just \"${command}\"";
mkXmonadProject = { name, workdir, windowCount, spawnPrograms, terminalCommands }:
''
Project {
projectName = "${name}",
projectStartHook = ${startHook}
projectStartHook =
do
let workdir = "${workdir}"
${lib.concatStringsSep "\n" (map mkXmonadProjectSpawnProgram spawnPrograms)}
${lib.concatStringsSep "\n" (map mkXmonadProjectTerminalCommand terminalCommands)}
replicateM_ ${toString windowCount} $ spawn $ terminal workdir
}
'';