nixos/home/modules/playerctl.nix

59 lines
1.4 KiB
Nix
Raw Normal View History

{ lib, config, pkgs, ... }:
let
cfg = config.snowhawk.playerctl;
2024-07-13 00:15:01 +00:00
keybindingsStr = lib.concatStringsSep "\n" (lib.mapAttrsToList
(hotkey: command:
lib.optionalString (command != null) ''
${hotkey}
${command}
'')
2024-07-15 09:36:37 +00:00
config.services.sxhkd.keybindings);
in
{
options.snowhawk.playerctl = {
enable = lib.mkEnableOption "playerctl";
};
config = lib.mkIf cfg.enable {
2024-07-16 10:32:01 +00:00
services.playerctld.enable = true;
2024-07-16 10:28:53 +00:00
systemd.user.services.playerctld = {
2024-07-16 10:32:01 +00:00
Unit.PartOf = lib.mkForce [ "graphical-session.target" ];
Install.WantedBy = lib.mkForce [ "graphical-session.target" ];
2024-07-16 10:28:53 +00:00
};
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
2024-07-13 00:44:48 +00:00
playerctl = "${pkgs.playerctl}/bin/playerctl";
in
{
keybindings = {
2024-07-13 00:44:48 +00:00
"XF86AudioPlay" = "${playerctl} play-pause";
"XF86AudioPrev" = "${playerctl} previous";
"XF86AudioNext" = "${playerctl} next";
};
};
};
}