xref: /freebsd/libexec/rc/rc.d/mixer (revision f99f0ee14e3af81c23150a6a340259ca8a33d01a)
10696600cSBjoern A. Zeeb#!/bin/sh -
20696600cSBjoern A. Zeeb#
30696600cSBjoern A. Zeeb# Copyright (c) 2004  The FreeBSD Project
40696600cSBjoern A. Zeeb# All rights reserved.
50696600cSBjoern A. Zeeb#
60696600cSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without
70696600cSBjoern A. Zeeb# modification, are permitted provided that the following conditions
80696600cSBjoern A. Zeeb# are met:
90696600cSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright
100696600cSBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer.
110696600cSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright
120696600cSBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer in the
130696600cSBjoern A. Zeeb#    documentation and/or other materials provided with the distribution.
140696600cSBjoern A. Zeeb#
150696600cSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
160696600cSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
170696600cSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
180696600cSBjoern A. Zeeb# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
190696600cSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
200696600cSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
210696600cSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
220696600cSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
230696600cSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
240696600cSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
250696600cSBjoern A. Zeeb# SUCH DAMAGE.
260696600cSBjoern A. Zeeb#
270696600cSBjoern A. Zeeb#
280696600cSBjoern A. Zeeb
290696600cSBjoern A. Zeeb# PROVIDE: mixer
300696600cSBjoern A. Zeeb# REQUIRE: FILESYSTEMS
310696600cSBjoern A. Zeeb# KEYWORD: nojail shutdown
320696600cSBjoern A. Zeeb
330696600cSBjoern A. Zeeb. /etc/rc.subr
340696600cSBjoern A. Zeeb
350696600cSBjoern A. Zeebname="mixer"
360696600cSBjoern A. Zeebdesc="Save and restore soundcard mixer values"
370696600cSBjoern A. Zeebrcvar="mixer_enable"
380696600cSBjoern A. Zeebstop_cmd="mixer_stop"
390696600cSBjoern A. Zeebstart_cmd="mixer_start"
400696600cSBjoern A. Zeebreload_cmd="mixer_start"
410696600cSBjoern A. Zeebextra_commands="reload"
420696600cSBjoern A. Zeeb
430696600cSBjoern A. Zeeb#
440696600cSBjoern A. Zeeb# List current mixer devices to stdout.
450696600cSBjoern A. Zeeb#
460696600cSBjoern A. Zeeblist_mixers()
470696600cSBjoern A. Zeeb{
480696600cSBjoern A. Zeeb	( cd /dev ; ls mixer* 2>/dev/null )
490696600cSBjoern A. Zeeb}
500696600cSBjoern A. Zeeb
510696600cSBjoern A. Zeeb#
520696600cSBjoern A. Zeeb# Save state of an individual mixer specified as $1
530696600cSBjoern A. Zeeb#
540696600cSBjoern A. Zeebmixer_save()
550696600cSBjoern A. Zeeb{
560696600cSBjoern A. Zeeb	local dev
570696600cSBjoern A. Zeeb
580696600cSBjoern A. Zeeb	dev="/dev/${1}"
590696600cSBjoern A. Zeeb	if [ -r ${dev} ]; then
60624a34b8SHans Petter Selasky		/usr/sbin/mixer -f ${dev} -o > /var/db/${1}-state 2>/dev/null
610696600cSBjoern A. Zeeb	fi
620696600cSBjoern A. Zeeb}
630696600cSBjoern A. Zeeb
640696600cSBjoern A. Zeeb#
650696600cSBjoern A. Zeeb# Restore the state of an individual mixer specified as $1
660696600cSBjoern A. Zeeb#
670696600cSBjoern A. Zeebmixer_restore()
680696600cSBjoern A. Zeeb{
690696600cSBjoern A. Zeeb	local file dev
700696600cSBjoern A. Zeeb
710696600cSBjoern A. Zeeb	dev="/dev/${1}"
720696600cSBjoern A. Zeeb	file="/var/db/${1}-state"
730696600cSBjoern A. Zeeb	if [ -r ${dev} -a -r ${file} ]; then
740696600cSBjoern A. Zeeb		/usr/sbin/mixer -f ${dev} `cat ${file}` > /dev/null
750696600cSBjoern A. Zeeb	fi
760696600cSBjoern A. Zeeb}
770696600cSBjoern A. Zeeb
780696600cSBjoern A. Zeeb#
790696600cSBjoern A. Zeeb# Restore state of all mixers
800696600cSBjoern A. Zeeb#
810696600cSBjoern A. Zeebmixer_start()
820696600cSBjoern A. Zeeb{
830696600cSBjoern A. Zeeb	local mixer
840696600cSBjoern A. Zeeb
850696600cSBjoern A. Zeeb	for mixer in `list_mixers`; do
860696600cSBjoern A. Zeeb		mixer_restore ${mixer}
870696600cSBjoern A. Zeeb	done
880696600cSBjoern A. Zeeb}
890696600cSBjoern A. Zeeb
900696600cSBjoern A. Zeeb#
910696600cSBjoern A. Zeeb# Save the state of all mixers
920696600cSBjoern A. Zeeb#
930696600cSBjoern A. Zeebmixer_stop()
940696600cSBjoern A. Zeeb{
950696600cSBjoern A. Zeeb	local mixer
960696600cSBjoern A. Zeeb
970696600cSBjoern A. Zeeb	for mixer in `list_mixers`; do
980696600cSBjoern A. Zeeb		mixer_save ${mixer}
990696600cSBjoern A. Zeeb	done
1000696600cSBjoern A. Zeeb}
1010696600cSBjoern A. Zeeb
1020696600cSBjoern A. Zeebload_rc_config $name
103*f99f0ee1SAlexander Leidinger
104*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj: config setting
105*f99f0ee1SAlexander Leidingermixer_svcj="NO"
106*f99f0ee1SAlexander Leidinger
1070696600cSBjoern A. Zeebrun_rc_command "$1"
108