From afe096f3737e7e64495a087f4d2ca825685edea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sun, 21 May 2023 21:24:29 +0200 Subject: [PATCH] audio-server: pause mpv in the early morning --- modules/audio-server.nix | 41 ++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/modules/audio-server.nix b/modules/audio-server.nix index 31e7096d..a892310a 100644 --- a/modules/audio-server.nix +++ b/modules/audio-server.nix @@ -151,18 +151,39 @@ ''); systemd = { - services.bluetooth-agent = lib.mkIf config.hardware.bluetooth.enable { - description = "Allow anyone to pair via Bluetooth"; - wantedBy = [ "multi-user.target" ]; - requires = [ "bluetooth.target" ]; - after = [ "bluetooth.service" ]; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.bluez-tools}/bin/bt-agent -c NoInputNoOutput"; - Restart = "on-failure"; - RestartSec = 60; + services = { + bluetooth-agent = lib.mkIf config.hardware.bluetooth.enable { + description = "Allow anyone to pair via Bluetooth"; + wantedBy = [ "multi-user.target" ]; + requires = [ "bluetooth.target" ]; + after = [ "bluetooth.service" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.bluez-tools}/bin/bt-agent -c NoInputNoOutput"; + Restart = "on-failure"; + RestartSec = 60; + }; + }; + + mpv-pause = { + script = '' + echo '{ "command": ["set_property", "pause", true] }' | ${pkgs.socat}/bin/socat - /tmp/mpvsocket + ''; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; }; }; + + timers.mpv-pause = { + wantedBy = [ "timers.target" ]; + timerConfig = { + Unit = "mpv-pause.service"; + OnCalendar = "*-*-* 05:30:00"; + }; + }; + user.services = { ledfx = { after = [ "pipewire.target" ];