#!/bin/bash #!/bin/bash . /etc/rc.conf . /etc/rc.conf . /etc/conf.d/alsa . /etc/conf.d/alsa . /etc/rc.d/functions . /etc/rc.d/functions case "$1" in case "$1" in start) start) stat_busy "Restoring ALSA Levels" stat_busy "Restoring ALSA Levels" /usr/sbin/alsactl $ALSA_ARGS restore | if /usr/sbin/alsactl $ALSA_ARGS restore; then # removed if [ $? -gt 0 ]; then < stat_fail < else < stat_done stat_done add_daemon alsa add_daemon alsa > else > stat_fail fi fi POWERSAVE=${POWERSAVE:-0} | POWERSAVE="${POWERSAVE:-0}" if [ -e /sys/module/snd_ac97_codec/parameters/power_save | if [[ -e /sys/module/snd_ac97_codec/parameters/power_save -a $POWERSAVE -ne 0 ]; then | && (( $POWERSAVE )); then # rewritten with proper echo $POWERSAVE > /sys/module/snd_ac97_codec/parameters echo $POWERSAVE > /sys/module/snd_ac97_codec/parameters [ -c /dev/dsp ] && echo 1 > /dev/dsp | [[ -c /dev/dsp ]] && echo 1 > /dev/dsp fi fi if [ -e /sys/module/snd_hda_intel/parameters/power_save \ | if [[ -e /sys/module/snd_hda_intel/parameters/power_save -a $POWERSAVE -ne 0 ]; then | && (( $POWERSAVE )); then # same here echo $POWERSAVE > /sys/module/snd_hda_intel/parameters/ echo $POWERSAVE > /sys/module/snd_hda_intel/parameters/ [ -c /dev/dsp ] && echo 1 > /dev/dsp | [[ -c /dev/dsp ]] && echo 1 > /dev/dsp fi fi ;; ;; stop) stop) SAVE_VOLUME=${SAVE_VOLUME:-yes} | # this is the section that really confused me, the error if [ "$SAVE_VOLUME" == "yes" ]; then | # i believe this to be a much better way of doing it. > SAVE_VOLUME="${SAVE_VOLUME:-yes}" > if [[ "$SAVE_VOLUME" = "yes" ]]; then stat_busy "Saving ALSA Levels" stat_busy "Saving ALSA Levels" /usr/sbin/alsactl $ALSA_ARGS store | /usr/sbin/alsactl $ALSA_ARGS store || { stat_fail; exit else else stat_busy "Stopping ALSA" stat_busy "Stopping ALSA" fi fi if [ "$MUTE_VOLUME" == "yes" ]; then | if [[ "$MUTE_VOLUME" = "yes" ]]; then /usr/bin/amixer -q set Master 0 mute | /usr/bin/amixer -q set Master 0 mute || { stat_fail; ex fi < if [ $? -gt 0 ]; then < stat_fail < else < stat_done < rm_daemon alsa < fi fi > stat_done > rm_daemon alsa ;; ;; restart) restart) $0 stop $0 stop sleep 1 sleep 1 $0 start $0 start ;; ;; *) *) echo "usage: $0 {start|stop|restart}" echo "usage: $0 {start|stop|restart}" esac esac