Subject: misc/15468: Startup file for saving/restoring mixer volumes
To: None <gnats-bugs@gnats.netbsd.org>
From: Julio Merino <juli@merino.net>
List: netbsd-bugs
Date: 02/03/2002 12:46:19
>Number:         15468
>Category:       misc
>Synopsis:       Startup file for saving/restoring mixer volumes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 03 03:49:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Julio Merino
>Release:        NetBSD 1.5ZA
>Organization:
>Environment:
	
	
System: NetBSD klamath.local 1.5ZA NetBSD 1.5ZA (KLAMATH) #1: Sat Feb 2 18:21:24 CET 2002 root@klamath.local:/home/juli/src/netbsd/sys/arch/i386/compile/KLAMATH i386
Architecture: i386
Machine: i386
>Description:
	The script attached to this PR is intended to be placed in /etc/rc.d.
	It uses two variables from /etc/rc.conf, $mixerctl and $mixers.
	The first one tells the script (/etc/rc.d/mixerctl) to save/restore
	mixer volumes at system startup/shutdown when is set to YES.
	The secons variable, $mixers, holds a list of mixer devices that
	we want to use.

	I have written this script with a workstation in mind. It is useful
	to have the same volumes (that you setup before) each time you boot.
	The script is included below.
>How-To-Repeat:
	
>Fix:
#!/bin/sh
# /etc/rc.d/mixerctl startup script

# PROVIDE: mixer
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="mixer"
command="/usr/bin/mixerctl"
rcvar="mixerctl"
start_cmd="mixer_start"
stop_cmd="mixer_stop"

mixer_start()
{
	echo -n "Setting mixer volumes:"
	for mixdev in $mixers; do
		echo -n " `basename $mixdev`"
		conffile="/etc/mixer/`basename $mixdev`"
		if [ -f $conffile ]; then
			$command -f $mixdev -w `cat $conffile` > /dev/null
		fi
	done
	echo "."
}

mixer_stop()
{
	echo -n "Saving mixer volumes:"
	if [ ! -d /etc/mixer ]; then
		rm -f /etc/mixer
		mkdir /etc/mixer
	fi
	for mixdev in $mixers; do
		echo -n " `basename $mixdev`"
		conffile="/etc/mixer/`basename $mixdev`"
		$command -f $mixdev -a > $conffile
	done
	echo "."
}

load_rc_config $name
run_rc_command "$1"
>Release-Note:
>Audit-Trail:
>Unformatted: