add sway displays

This commit is contained in:
tristan 2023-05-12 15:42:19 +01:00
parent 7d549912c6
commit 954c85f23b
5 changed files with 81 additions and 43 deletions

View file

@ -2,8 +2,8 @@
with lib;
let
scripts = config.programs.scripts;
hotkeyType = types.submodule ({...}: {
hotkeyType = types.submodule ({ ... }: {
options = {
key = mkOption {
description = "the key";
@ -18,8 +18,8 @@ let
};
};
});
scriptType = types.submodule ({...}: {
scriptType = types.submodule ({ ... }: {
options = {
name = mkOption {
description = "name of the executable";
@ -30,7 +30,7 @@ let
hotkeys = mkOption {
type = types.listOf hotkeyType;
description = "keys that run this script";
default = [];
default = [ ];
};
install = mkOption {
type = types.bool;
@ -38,19 +38,24 @@ let
};
};
});
scriptToPackage = script:
pkgs.writeShellScriptBin script.name script.text;
scriptExec = { script, hotkey }:
"${scriptToPackage script}/bin/${script.name} ${hotkey.args}";
installScripts = scripts:
(map scriptToPackage (filter ( s: s.install ) scripts));
(map scriptToPackage (filter (s: s.install) scripts));
bindScript = script: concatStrings (
map ( hotkey: ''
bind = ${hotkey.modifier}, ${hotkey.key}, exec, ${scriptToPackage script}/bin/${script.name} ${hotkey.args}
'' ) script.hotkeys);
bindScripts = scripts:
map
(hotkey: ''
bind = ${hotkey.modifier}, ${hotkey.key}, exec, ${scriptExec {inherit script hotkey;}}
'')
script.hotkeys);
bindScripts = scripts:
"# === USER SCRIPTS MODULE ===\n"
+ concatStringsSep "\n" (map bindScript scripts);
@ -59,7 +64,7 @@ in
options.programs = {
scripts = mkOption {
type = types.listOf scriptType;
default = [];
default = [ ];
};
};
@ -69,5 +74,5 @@ in
wayland.windowManager.hyprland.extraConfig = bindScripts scripts;
}];
};
}