From 02624758b192c33de951b208a7b159dd6c2856e4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 2 Oct 2012 11:09:54 -0400 Subject: [PATCH] Use udev to restore ALSA volume settings Alsa-utils provides a udev rule to restore volume settings, so use that instead of restoring them from a systemd service. The "alsa-store" service saves the settings on shutdown. --- modules/services/audio/alsa.nix | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/modules/services/audio/alsa.nix b/modules/services/audio/alsa.nix index fa63bc74cfc5d7..ff08f21a48574b 100644 --- a/modules/services/audio/alsa.nix +++ b/modules/services/audio/alsa.nix @@ -45,29 +45,19 @@ in environment.systemPackages = [ alsaUtils ]; - boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss"; - - jobs.alsa = - { description = "ALSA Volume Settings"; - - startOn = "stopped udevtrigger"; + # ALSA provides a udev rule for restoring volume settings. + services.udev.packages = [ alsaUtils ]; - preStart = - '' - mkdir -m 0755 -p $(dirname ${soundState}) - - # Try to restore the sound state. - ${alsaUtils}/sbin/alsactl --ignore init || true - ${alsaUtils}/sbin/alsactl --ignore -f ${soundState} restore || true - ''; + boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss"; - postStop = - '' - # Save the sound state. - ${alsaUtils}/sbin/alsactl --ignore -f ${soundState} store - ''; + boot.systemd.services."alsa-store" = + { description = "Store Sound Card State"; + wantedBy = [ "shutdown.target" ]; + before = [ "shutdown.target" ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + serviceConfig.ExecStart = "${alsaUtils}/sbin/alsactl store --ignore"; }; - }; }