nixfiles/hosts/raspberry/services/music-friend/process-media-controls.nix

24 lines
703 B
Nix
Raw Normal View History

2022-01-29 18:06:26 +00:00
{ pkgs, ... }:
let
process-media-controls = pkgs.writeText "process-media-controls"
(builtins.readFile ./process-media-controls.py);
in {
systemd.services.process-media-controls = {
requires = [ "network.target" "pulseaudio.service" ];
after = [ "network.target" "pulseaudio.service" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.pulseaudio ];
script = let
python = pkgs.python39.withPackages
(ps: with ps; [ pkgs.python39Packages.evdev ]);
in ''
export PULSE_SERVER=127.0.0.1
(${python.interpreter} ${process-media-controls}) || true
'';
serviceConfig = {
Restart = "always";
StartLimitAction = "none";
};
};
}