moar modules
This commit is contained in:
parent
a1175ba492
commit
011009d22f
17 changed files with 556 additions and 240 deletions
|
|
@ -3,6 +3,22 @@ with lib;
|
|||
let
|
||||
scripts = config.programs.scripts;
|
||||
|
||||
hotkeyType = types.submodule ({...}: {
|
||||
options = {
|
||||
key = mkOption {
|
||||
description = "the key";
|
||||
};
|
||||
modifier = mkOption {
|
||||
description = "modifiers for the key";
|
||||
default = "SUPER";
|
||||
};
|
||||
args = mkOption {
|
||||
description = "args for the script when use this key";
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
scriptType = types.submodule ({...}: {
|
||||
options = {
|
||||
name = mkOption {
|
||||
|
|
@ -11,9 +27,10 @@ let
|
|||
text = mkOption {
|
||||
description = "the text of the script";
|
||||
};
|
||||
hotkey = mkOption {
|
||||
description = "the key that run this script";
|
||||
default = "";
|
||||
hotkeys = mkOption {
|
||||
type = types.listOf hotkeyType;
|
||||
description = "keys that run this script";
|
||||
default = [];
|
||||
};
|
||||
install = mkOption {
|
||||
type = types.bool;
|
||||
|
|
@ -22,12 +39,16 @@ let
|
|||
};
|
||||
});
|
||||
|
||||
scriptToPackage = script: pkgs.writeShellScriptBin script.name script.text;
|
||||
installScripts = scripts: (map scriptToPackage (filter ( s: s.install ) scripts));
|
||||
scriptToPackage = script:
|
||||
pkgs.writeShellScriptBin script.name script.text;
|
||||
|
||||
installScripts = scripts:
|
||||
(map scriptToPackage (filter ( s: s.install ) scripts));
|
||||
|
||||
bindScript = script: if script.hotkey != "" then ''
|
||||
bind = SUPER, ${script.hotkey}, exec, ${scriptToPackage script}/bin/${script.name}
|
||||
'' else "";
|
||||
bindScript = script: concatStrings (
|
||||
map ( hotkey: ''
|
||||
bind = ${hotkey.modifier}, ${hotkey.key}, exec, ${scriptToPackage script}/bin/${script.name} ${hotkey.args}
|
||||
'' ) script.hotkeys);
|
||||
|
||||
bindScripts = scripts:
|
||||
"# === USER SCRIPTS MODULE ===\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue