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 96fb315
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions modules/hotkeys.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Global hotkeys (user-defined keyboard shortcuts):
{ config, lib, ... }:
{ pkgs, config, lib, ... }:
let
cfg = config.programs.plasma;

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 = 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
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 96fb315

Please sign in to comment.