Skip to content

Commit

Permalink
Use udev to restore ALSA volume settings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edolstra committed Oct 2, 2012
1 parent 666620c commit 0262475
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions modules/services/audio/alsa.nix
Expand Up @@ -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";
};

};

}

0 comments on commit 0262475

Please sign in to comment.