sxhkd: extract module from playerctld

This commit is contained in:
Zynh Ludwig 2024-09-27 22:21:40 -07:00
parent 962f1cf796
commit c06691c45f
2 changed files with 40 additions and 31 deletions

View file

@ -2,14 +2,6 @@
let let
cfg = config.snowhawk.playerctl; cfg = config.snowhawk.playerctl;
keybindingsStr = lib.concatStringsSep "\n" (lib.mapAttrsToList
(hotkey: command:
lib.optionalString (command != null) ''
${hotkey}
${command}
'')
config.services.sxhkd.keybindings);
in in
{ {
options.snowhawk.playerctl = { options.snowhawk.playerctl = {
@ -27,30 +19,14 @@ in
playerctl playerctl
]; ];
systemd.user.services.sxhkd = { snowhawk.sxhkd.enable = lib.mkDefault true;
Unit = {
Description = "sxhkd service";
PartOf = [ "graphical-session.target" ];
};
Service = {
Type = "exec";
ExecStart = "${pkgs.sxhkd}/bin/sxhkd";
};
Install.WantedBy = [ "graphical-session.target" ];
};
xdg.configFile."sxhkd/sxhkdrc".text = keybindingsStr; services.sxhkd.keybindings =
let playerctl = "${pkgs.playerctl}/bin/playerctl";
services.sxhkd = in {
let
playerctl = "${pkgs.playerctl}/bin/playerctl";
in
{
keybindings = {
"XF86AudioPlay" = "${playerctl} play-pause"; "XF86AudioPlay" = "${playerctl} play-pause";
"XF86AudioPrev" = "${playerctl} previous"; "XF86AudioPrev" = "${playerctl} previous";
"XF86AudioNext" = "${playerctl} next"; "XF86AudioNext" = "${playerctl} next";
}; };
}; };
};
} }

33
home/modules/sxhkd.nix Normal file
View file

@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:
let
cfg = config.snowhawk.sxhkd;
in
{
options.snowhawk.sxhkd = {
enable = lib.mkEnableOption "custom sxhkd home-manager module";
};
config = lib.mkIf cfg.enable {
systemd.user.services.sxhkd = {
Unit = {
Description = "sxhkd service";
PartOf = [ "graphical-session.target" ];
};
Service = {
Type = "exec";
ExecStart = "${pkgs.sxhkd}/bin/sxhkd";
};
Install.WantedBy = [ "graphical-session.target" ];
};
xdg.configFile."sxhkd/sxhkdrc".text =
lib.concatStringsSep "\n" (lib.mapAttrsToList
(hotkey: command:
lib.optionalString (command != null) ''
${hotkey}
${command}
'')
config.services.sxhkd.keybindings);
};
}