nixos/home/modules/playerctl.nix

68 lines
1.5 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:28:53 +00:00
systemd.user.services.playerctld = {
Unit = {
Description = "MPRIS media player daemon";
PartOf = [ "graphical-session.target" ];
};
Install.WantedBy = [ "graphical-session.target" ];
Service = {
ExecStart = "${pkgs.playerctl}/bin/playerctld";
Type = "dbus";
BusName = "org.mpris.MediaPlayer2.playerctld";
};
};
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";
};
};
};
}