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 { name = mkOption {
type = types.str; type = types.str;
}; };
startHook = mkOption { workdir = mkOption {
type = types.lines; 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 = [ ];
};
}; };
}; };
}; mkXmonadProjectSpawnProgram = program:
"spawn \"${program}\"";
mkXmonadProject = { name, startHook }: mkXmonadProjectTerminalCommand = command:
"spawn $ terminal' workdir $ Just \"${command}\"";
mkXmonadProject = { name, workdir, windowCount, spawnPrograms, terminalCommands }:
'' ''
Project { Project {
projectName = "${name}", 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
} }
''; '';