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.
This commit is contained in:
Eelco Dolstra 2012-10-02 11:09:54 -04:00
parent 666620cdd5
commit 02624758b1

View File

@ -45,29 +45,19 @@ in
environment.systemPackages = [ alsaUtils ]; environment.systemPackages = [ alsaUtils ];
# ALSA provides a udev rule for restoring volume settings.
services.udev.packages = [ alsaUtils ];
boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss"; boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss";
jobs.alsa = boot.systemd.services."alsa-store" =
{ description = "ALSA Volume Settings"; { description = "Store Sound Card State";
wantedBy = [ "shutdown.target" ];
startOn = "stopped udevtrigger"; before = [ "shutdown.target" ];
unitConfig.DefaultDependencies = "no";
preStart = serviceConfig.Type = "oneshot";
'' serviceConfig.ExecStart = "${alsaUtils}/sbin/alsactl store --ignore";
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
'';
postStop =
''
# Save the sound state.
${alsaUtils}/sbin/alsactl --ignore -f ${soundState} store
'';
}; };
}; };
} }