Skip to content

Commit

Permalink
add systemd-cat to hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarewk committed Oct 23, 2023
1 parent 633eacf commit cb332b2
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions modules/hotkeys.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let
group = rec {
name = "plasma-manager-commands";
desktop = "${name}.desktop";
description = "Plasma (Home) Manager Commands";
description = "Home (Plasma) Manager";
};

commandType = { name, ... }: {
Expand Down Expand Up @@ -39,6 +39,28 @@ let
type = lib.types.str;
description = "The command to execute.";
};

logs.enabled = lib.mkOption {
type = types.bool;
default = true;
description = "Connect command's stdin and stdout to systemd journal with systemd-cat.";
};

logs.identifier = lib.mkOption {
type = lib.types.str;
default = lib.trivial.pipe name [
lib.strings.toLower
(builtins.replaceStrings [" "] ["-"])
(n: "${group.name}-${n}")
];
description = "Identifier passed down to systemd-cat.";
};

logs.extraArgs = lib.mkOption {
type = lib.types.str;
default = "";
description = "Additional arguments provided to systemd-cat.";
};
};
};
in
Expand All @@ -61,7 +83,10 @@ in
actions = lib.mapAttrs
(_: command: {
name = command.name;
exec = command.command;
exec =
if command.logs.enabled then
"${pkgs.systemd}/bin/systemd-cat --identifier=${command.logs.identifier} ${command.logs.extraArgs} ${command.command}"
else command.command;
})
cfg.hotkeys.commands;
};
Expand Down

0 comments on commit cb332b2

Please sign in to comment.