nixos/home/modules/playerctl.nix

57 lines
1.2 KiB
Nix
Raw Normal View History

{ lib, config, pkgs, ... }:
let
cfg = config.snowhawk.playerctl;
2024-07-13 00:15:01 +00:00
sxhkdCfg = config.services.sxhkd;
keybindingsStr = lib.concatStringsSep "\n" (lib.mapAttrsToList
(hotkey: command:
lib.optionalString (command != null) ''
${hotkey}
${command}
'')
sxhkdCfg.keybindings);
in
{
options.snowhawk.playerctl = {
enable = lib.mkEnableOption "playerctl";
};
config = lib.mkIf cfg.enable {
services.playerctld.enable = true;
home.packages = with pkgs; [
playerctl
];
2024-07-12 06:43:08 +00:00
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" ];
};
};
2024-07-13 00:15:01 +00:00
xdg.configFile."sxhkd/sxhkdrc".text = keybindingsStr;
services.sxhkd =
let
playerctlcmd = "${pkgs.playerctl}/bin/playerctl";
in
{
keybindings = {
"XF86AudioPlay" = "${playerctlcmd} play-pause";
"XF86AudioPrev" = "${playerctlcmd} previous";
"XF86AudioNext" = "${playerctlcmd} next";
};
};
};
}