mixer revision 127478
1127043Sjhb#!/bin/sh - 2127043Sjhb# 3127043Sjhb# Copyright (c) 2004 The FreeBSD Project 4127043Sjhb# All rights reserved. 5127043Sjhb# 6127043Sjhb# Redistribution and use in source and binary forms, with or without 7127043Sjhb# modification, are permitted provided that the following conditions 8127043Sjhb# are met: 9127043Sjhb# 1. Redistributions of source code must retain the above copyright 10127043Sjhb# notice, this list of conditions and the following disclaimer. 11127043Sjhb# 2. Redistributions in binary form must reproduce the above copyright 12127043Sjhb# notice, this list of conditions and the following disclaimer in the 13127043Sjhb# documentation and/or other materials provided with the distribution. 14127043Sjhb# 15127043Sjhb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16127043Sjhb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17127043Sjhb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18127043Sjhb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19127043Sjhb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20127043Sjhb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21127043Sjhb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22127043Sjhb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23127043Sjhb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24127043Sjhb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25127043Sjhb# SUCH DAMAGE. 26127043Sjhb# 27127043Sjhb# $FreeBSD: head/etc/rc.d/mixer 127478 2004-03-27 09:26:22Z dougb $ 28127043Sjhb# 29127043Sjhb 30127043Sjhb# PROVIDE: mixer 31127043Sjhb# REQUIRE: LOGIN usbd 32127478Sdougb# KEYWORD: FreeBSD nojail shutdown 33127043Sjhb 34127043Sjhb. /etc/rc.subr 35127043Sjhb 36127043Sjhbname="mixer" 37127043Sjhbstop_cmd="mixer_stop" 38127043Sjhbstart_cmd="mixer_start" 39127043Sjhbreload_cmd="mixer_start" 40127043Sjhbextra_commands="reload" 41127043Sjhb 42127043Sjhb# 43127043Sjhb# List current mixer devices to stdout. 44127043Sjhb# 45127043Sjhblist_mixers() 46127043Sjhb{ 47127043Sjhb ( cd /dev ; ls mixer* 2>/dev/null ) 48127043Sjhb} 49127043Sjhb 50127043Sjhb# 51127043Sjhb# Save state of an individual mixer specified as $1 52127043Sjhb# 53127043Sjhbmixer_save() 54127043Sjhb{ 55127478Sdougb local dev 56127043Sjhb 57127043Sjhb dev="/dev/${1}" 58127043Sjhb if [ -r ${dev} ]; then 59127478Sdougb /usr/sbin/mixer -f ${dev} -s > /var/db/${1}-state 2>/dev/null 60127043Sjhb fi 61127043Sjhb} 62127043Sjhb 63127043Sjhb# 64127043Sjhb# Restore the state of an individual mixer specified as $1 65127043Sjhb# 66127043Sjhbmixer_restore() 67127043Sjhb{ 68127043Sjhb local file dev 69127043Sjhb 70127043Sjhb dev="/dev/${1}" 71127478Sdougb file="/var/db/${1}-state" 72127043Sjhb if [ -r ${dev} -a -r ${file} ]; then 73127043Sjhb /usr/sbin/mixer -f ${dev} `cat ${file}` > /dev/null 74127043Sjhb fi 75127043Sjhb} 76127043Sjhb 77127043Sjhb# 78127043Sjhb# Restore state of all mixers 79127043Sjhb# 80127043Sjhbmixer_start() 81127043Sjhb{ 82127043Sjhb local mixer 83127043Sjhb 84127043Sjhb for mixer in `list_mixers`; do 85127043Sjhb mixer_restore ${mixer} 86127043Sjhb done 87127043Sjhb} 88127043Sjhb 89127043Sjhb# 90127043Sjhb# Save the state of all mixers 91127043Sjhb# 92127043Sjhbmixer_stop() 93127043Sjhb{ 94127043Sjhb local mixer 95127043Sjhb 96127043Sjhb for mixer in `list_mixers`; do 97127043Sjhb mixer_save ${mixer} 98127043Sjhb done 99127043Sjhb} 100127043Sjhb 101127043Sjhbload_rc_config $name 102127043Sjhbrun_rc_command "$1" 103