]> Frank Brehm's Git Trees - config/samara/etc.git/commitdiff
saving uncommitted changes in /etc prior to emerge run
authorfbrehm <fbrehm@samara.profitbricks.localdomain>
Mon, 12 Mar 2012 16:32:57 +0000 (17:32 +0100)
committerroot <root@samara.profitbricks.localdomain>
Mon, 12 Mar 2012 16:32:57 +0000 (17:32 +0100)
.etckeeper
conf.d/._cfg0000_alsasound [new file with mode: 0644]
init.d/._cfg0000_alsasound [new file with mode: 0755]

index 19e33ea547caa6f92181c47749b5b94735680609..d6d851ab411fc18185b5e294aada8a98a72f8770 100755 (executable)
@@ -219,6 +219,7 @@ maybe chmod 0644 './chromium/default'
 maybe chmod 0644 './colordiffrc'
 maybe chmod 0644 './colordiffrc-lightbg'
 maybe chmod 0755 './conf.d'
+maybe chmod 0644 './conf.d/._cfg0000_alsasound'
 maybe chmod 0644 './conf.d/._cfg0000_libvirtd'
 maybe chmod 0644 './conf.d/acpid'
 maybe chmod 0644 './conf.d/alsasound'
@@ -929,6 +930,7 @@ maybe chmod 0644 './imlib/im_palette-tiny.pal'
 maybe chmod 0644 './imlib/im_palette.pal'
 maybe chmod 0644 './imlib/imrc'
 maybe chmod 0755 './init.d'
+maybe chmod 0755 './init.d/._cfg0000_alsasound'
 maybe chmod 0755 './init.d/._cfg0000_dbus'
 maybe chmod 0755 './init.d/._cfg0000_libvirtd'
 maybe chmod 0755 './init.d/NetworkManager'
diff --git a/conf.d/._cfg0000_alsasound b/conf.d/._cfg0000_alsasound
new file mode 100644 (file)
index 0000000..6fec8f5
--- /dev/null
@@ -0,0 +1,15 @@
+# RESTORE_ON_START:
+# Do you want to restore your mixer settings?  If not, your cards will be
+# muted.
+# no - Do not restore state
+# yes - Restore state
+
+RESTORE_ON_START="yes"
+
+# SAVE_ON_STOP:
+# Do you want to save changes made to your mixer volumes when alsasound
+# stops? 
+# no - Do not save state
+# yes - Save state
+
+SAVE_ON_STOP="yes"
diff --git a/init.d/._cfg0000_alsasound b/init.d/._cfg0000_alsasound
new file mode 100755 (executable)
index 0000000..e3c8dd9
--- /dev/null
@@ -0,0 +1,83 @@
+#!/sbin/runscript
+# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r5,v 1.1 2012/02/20 09:03:53 chainsaw Exp $
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+alsastatedir=/var/lib/alsa
+alsascrdir=/etc/alsa.d
+
+extra_commands="save restore"
+
+depend() {
+       need localmount
+       after bootmisc modules isapnp coldplug hotplug
+}
+
+restore() {
+       ebegin "Restoring Mixer Levels"
+
+       if [ ! -r "${alsastatedir}/asound.state" ] ; then
+               ewarn "No mixer config in ${alsastatedir}/asound.state, you have to unmute your card!"
+               eend 0
+               return 0
+       fi
+
+       local cards="$(sed -n -e 's/ *\([[:digit:]]*\) .*/\1/p' /proc/asound/cards)"
+       local CARDNUM
+       for cardnum in ${cards}; do
+               [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+               [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+               [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+               [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+               alsactl -I -f "${alsastatedir}/asound.state" restore ${cardnum} \
+                       || ewarn "Errors while restoring defaults, ignoring"
+       done
+
+       for ossfile in "${alsastatedir}"/oss/card*_pcm* ; do
+               [ -e "${ossfile}" ] || continue
+               # We use cat because I'm not sure if cp works properly on /proc
+               local procfile=${ossfile##${alsastatedir}/oss}
+               procfile="$(echo "${procfile}" | sed -e 's,_,/,g')"
+               if [ -e /proc/asound/"${procfile}"/oss ] ; then
+                   cat "${ossfile}" > /proc/asound/"${procfile}"/oss 
+               fi
+       done
+
+       eend 0
+}
+
+save() {
+       ebegin "Storing ALSA Mixer Levels"
+
+       mkdir -p "${alsastatedir}"
+       if ! alsactl -f "${alsastatedir}/asound.state" store; then
+               eerror "Error saving levels."
+               eend 1
+               return 1
+       fi
+
+       for ossfile in /proc/asound/card*/pcm*/oss; do
+               [ -e "${ossfile}" ] || continue
+               local device=${ossfile##/proc/asound/} ; device=${device%%/oss}
+               device="$(echo "${device}" | sed -e 's,/,_,g')"
+               mkdir -p "${alsastatedir}/oss/"
+               cp "${ossfile}" "${alsastatedir}/oss/${device}"
+       done
+
+       eend 0
+}
+
+start() {
+       if [ "${RESTORE_ON_START}" = "yes" ]; then
+               restore
+       fi
+
+       return 0
+}
+
+stop() {
+       if [ "${SAVE_ON_STOP}" = "yes" ]; then
+               save
+       fi
+       return 0
+}