From 052508dc030cfe195f7c1adfad399933762e79e2 Mon Sep 17 00:00:00 2001 From: Krzysztof Nazarewski Date: Mon, 23 Oct 2023 12:59:23 +0200 Subject: [PATCH] add `systemd-cat` to hotkeys see https://github.com/bugaevc/wl-clipboard/issues/201 --- modules/hotkeys.nix | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/hotkeys.nix b/modules/hotkeys.nix index b546b51c..2ac3d36b 100644 --- a/modules/hotkeys.nix +++ b/modules/hotkeys.nix @@ -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, ... }: { @@ -39,6 +39,28 @@ let type = lib.types.str; description = "The command to execute."; }; + + logs.enabled = lib.mkOption { + type = lib.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 @@ -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; };