Ignore:
Timestamp:
09/10/2005 02:22:41 AM (19 years ago)
Author:
DJ Lucas <dj@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 6.2, 6.2.0, 6.2.0-rc1, 6.2.0-rc2, 6.3, 6.3-rc1, 6.3-rc2, 6.3-rc3, 7.10, 7.4, 7.5, 7.6, 7.6-blfs, 7.6-systemd, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, basic, bdubbs/svn, elogind, gnome, kde5-13430, kde5-14269, kde5-14686, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, krejzi/svn, lazarus, lxqt, nosym, perl-modules, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, systemd-11177, systemd-13485, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
5933e09
Parents:
3988b2b
Message:

updated alsa restore script for new udev

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@5037 af4574ff-66df-0310-9fd7-8a98e5e911e0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • multimedia/libdriv/alsa-utils.xml

    r3988b2b ra40efd2c  
    112112      <application>ALSA Utilities</application> to change this.</para>
    113113
    114       <para>The first time the <filename class='directory'>dev.d</filename>
     114      <para>The first time the <filename>alsa-restore</filename>
    115115      script below is run, it will complain
    116116      that there is no state in <filename>/etc/asound.state</filename>. 
     
    122122
    123123      <para>The volume settings will be restored from the saved state using a
    124       <filename class='directory'>dev.d</filename> handler script that will
    125       execute when the device is detected
    126       during boot (when plugged in for USB devices).</para>
    127 
    128       <note>
    129         <para>For versions of udev greater than 0.58, this script will
    130         not work by default.  You'll have to add dev.d compatibility by adding
    131         a udev rules file that contains the line
    132         'RUN="/sbin/udev_send_devd" to continue using the now depreciated
    133         dev.d system.</para>
    134       </note>
     124      shell script called by <application>Udev</application> that will
     125      execute when the device is detected (during boot or when plugged in for
     126      USB devices).</para>
    135127
    136128      <para>  While still the
    137129      <systemitem class="username">root</systemitem> user, create the
    138       <filename class='directory'>dev.d</filename> script with the following
    139       commands:</para>
    140 
    141 <screen role="root"><userinput>install -v -d -m755 /etc/dev.d/snd &amp;&amp;
    142 cat &gt; /etc/dev.d/snd/alsa.dev &lt;&lt; "EOF"
     130      <filename>/etc/udev/scripts/alsa-restore</filename> script with
     131      the following commands:</para>
     132
     133<screen role="root"><userinput>install -v -d -m754 /etc/udev/scripts &amp;&amp;
     134cat &gt; /etc/udev/scripts/alsa-restore &lt;&lt; "EOF"
    143135#!/bin/sh -e
    144 # This script is called by udevd when a change in a device is
    145 # detected, including initial detection upon bootup.
    146 # udevd sets the environment variables ACTION and DEVNAME.
    147 
    148 [ "$ACTION" = "add" ] || exit 0
    149 DEV_BASENAME="${DEVNAME##*/}"
    150 N="${DEV_BASENAME#controlC}"
    151 case "$DEV_BASENAME" in
    152     controlC[0-7])
    153         x=0
    154         while [ $x -lt 20 ]; do
    155             # Wait up to 20 seconds for /usr to be mounted if necessary
    156             if [ -f /usr/sbin/alsactl ]; then
    157                 /usr/sbin/alsactl restore $N
    158                 exit 0
    159             fi
    160             sleep 1
    161             x=`expr $x + 1`
    162         done &amp; # Put the while command in the background and continue
    163     ;;
    164 esac
    165 exit 0
     136# Begin /etc/udev/scripts/alsa-restore
     137# $1 is (the numbered device "%n") passed in by udev/kernel.
     138
     139x=0
     140
     141# Give up to 20 seconds for /usr to be mounted
     142while [ "${x}" -lt 20 ]
     143do
     144    sleep 1
     145    if [ -f /usr/sbin/alsactl ]; then
     146        /usr/sbin/alsactl restore "${1}"
     147        exit 0
     148    fi
     149    x=`expr "${x}" + 1`
     150done &amp; # Put the loop in the background
     151
     152# End /etc/udev/scripts/alsa-restore
    166153EOF
    167 chmod -v 755 /etc/dev.d/snd/alsa.dev</userinput></screen>
    168 
    169 
    170       <para>You may wish to do additional configuration on a per card basis.
    171       For example, if you wish to load soundfont banks, use the following
    172       sample script:</para>
    173 
    174 <screen>#!/bin/sh -e
    175 # Begin /etc/dev.d/snd/<replaceable>[DEVICE]</replaceable>/asfxload.dev
    176 
    177 x=0
    178     while [ $x -lt 20 ]; do
    179         # Wait up to 20 seconds for /usr to be mounted if necessary
    180         if [ -f /usr/bin/asfxload ]; then
    181             # Load 8 MB sountfont bank
    182             /usr/bin/asfxload /usr/share/sounds/sf2/8mbgmsfx.sf2 -D "<replaceable>[ALSA device string]</replaceable>"
    183             exit 0
    184         fi
    185         sleep 1
    186         x=`expr $x + 1`
    187     done &amp; # Put the while command in the background and continue
    188 
    189 exit 0
    190 # End /etc/dev.d/snd/<replaceable>[DEVICE]</replaceable>/asfxload.dev</screen>
     154chmod -v 754 /etc/udev/scripts/alsa-restore</userinput></screen>
     155
     156      <para>Finally, again as the
     157      <systemitem class="username">root</systemitem> user, install a new
     158      <application>Udev</application> rules file to create the audio
     159      device nodes and run the restore script:</para>
     160
     161<screen role="root"><userinput>cat &gt; /etc/udev/rules.d/15-alsa.rules &lt;&lt; "EOF"
     162# Give the audio group ownership of sound devices
     163SUBSYSTEM=="sound",       GROUP="audio"
     164SUBSYSTEM=="snd",         GROUP="audio"
     165
     166# ALSA Devices
     167# When a sound device is detected, restore the volume settings
     168KERNEL=="controlC[0-9]*", ACTION=="add", NAME="snd/%k", RUN="/etc/udev/scripts/alsa-restore %n"
     169KERNEL="hw[CD0-9]*",      NAME="snd/%k"
     170KERNEL="pcm[CD0-9cp]*",   NAME="snd/%k"
     171KERNEL="midiC[D0-9]*",    NAME="snd/%k"
     172KERNEL="timer",           NAME="snd/%k"
     173KERNEL="seq",             NAME="snd/%k"
     174EOF
     175chmod 644 /etc/udev/rules.d/15-alsa.rules</userinput></screen>
    191176
    192177    </sect3>
Note: See TracChangeset for help on using the changeset viewer.