From 6f7991184dc95d54200dc9651fc725dd1b1033c6 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 27 Feb 2024 19:08:53 +0300 Subject: [PATCH] home/wm: simplify xmonad project settings --- home/modules/window_manager/xmonad.nix | 33 +++++++++++++++++--- nixos/hosts/home/xmonad_projects.secret.nix | Bin 914 -> 1544 bytes 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/home/modules/window_manager/xmonad.nix b/home/modules/window_manager/xmonad.nix index 1292284..e14a742 100644 --- a/home/modules/window_manager/xmonad.nix +++ b/home/modules/window_manager/xmonad.nix @@ -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 } ''; diff --git a/nixos/hosts/home/xmonad_projects.secret.nix b/nixos/hosts/home/xmonad_projects.secret.nix index da2efeabae85e028b37803fd6f1420e5eb69d168..81343466560a1216655867751ec4616236cc0936 100644 GIT binary patch literal 1544 zcmV+j2KV^@M@dveQdv+`0HFo45?$!BUi3dq1s)D=YkNR||4x=1-f#3$QmPj$GCr*` z=*Fj^`?Mb=3!NMvZ7jbp0aol4Mwy`pI|K->lehM7bqP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