about summary refs log tree commit diff
path: root/modules/services/audio
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-02 11:09:54 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-02 11:09:54 -0400
commit02624758b192c33de951b208a7b159dd6c2856e4 (patch)
treed43ded26e0bd6361c5c3bce98a93ca75e84e06bb /modules/services/audio
parent666620cdd50a1af57aa9b40faea2bcd828b3281c (diff)
downloadnixlib-02624758b192c33de951b208a7b159dd6c2856e4.tar
nixlib-02624758b192c33de951b208a7b159dd6c2856e4.tar.gz
nixlib-02624758b192c33de951b208a7b159dd6c2856e4.tar.bz2
nixlib-02624758b192c33de951b208a7b159dd6c2856e4.tar.lz
nixlib-02624758b192c33de951b208a7b159dd6c2856e4.tar.xz
nixlib-02624758b192c33de951b208a7b159dd6c2856e4.tar.zst
nixlib-02624758b192c33de951b208a7b159dd6c2856e4.zip
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.
Diffstat (limited to 'modules/services/audio')
-rw-r--r--modules/services/audio/alsa.nix30
1 files changed, 10 insertions, 20 deletions
diff --git a/modules/services/audio/alsa.nix b/modules/services/audio/alsa.nix
index fa63bc74cfc5..ff08f21a4857 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";
       };
-
   };
 
 }