Talk:ALSA: Difference between revisions
From ArmadeusWiki
(Use audio devices as non-root user) |
mNo edit summary |
||
| Line 2: | Line 2: | ||
# Create a group that will get permission on the audio device | # Create a group that will get permission on the audio device | ||
# Add the non-root user | # Add the non-root user to this group. | ||
# Give permission to this group at boot time. | # Give permission to this group at boot time. | ||
| Line 11: | Line 11: | ||
<pre class="apf"> | <pre class="apf"> | ||
u= | u=guest # the non-root username | ||
g=audio # the group that will get permissions on the resources | g=audio # the group that will get permissions on the resources | ||
| Line 28: | Line 28: | ||
cat <<eof >/etc/init.d/S60alsa | cat <<eof >/etc/init.d/S60alsa | ||
#!/bin/sh | #!/bin/sh | ||
# The spi_imx module does not seem to be required by the ALSA one. | # The spi_imx module does not seem to be required by the ALSA one. | ||
modprobe snd-imx-alsa-tsc2102 | modprobe snd-imx-alsa-tsc2102 | ||
# wait for the creation of all nodes | # wait for the creation of all nodes | ||
sleep 2 | sleep 2 | ||
# give permissions of the sound device to the audio group | # give permissions of the sound device to the audio group | ||
chown root:audio /dev/snd/* | chown root:audio /dev/snd/* | ||
eof | eof | ||
chmod a+x /etc/init.d/S60alsa | |||
</pre> | </pre> | ||
After reboot, you should be able to play audio | After reboot, you should be able to play audio files as ''guest'' user. | ||
Revision as of 14:57, 28 November 2009
Use audio devices as non-root user
- Create a group that will get permission on the audio device
- Add the non-root user to this group.
- Give permission to this group at boot time.
To do this, run the following command as root on your APF. Don't forget to adjust the u and g variables!
| Warning: If you already have a script loading the ALSA module at boot time and called S60alsa, it will be overwritten by this script. |
u=guest # the non-root username
g=audio # the group that will get permissions on the resources
# Create the new group:
addgroup $g
# Add the non-root user to the group:
l=`grep $g /etc/group`
ug=`echo $l | awk -F : '{print $4}'`
sed "
/$l/ c\
$l`! [ $ug ] || echo ,`$u
" /etc/group > /etc/group
# Give permission to the group at boot time:
cat <<eof >/etc/init.d/S60alsa
#!/bin/sh
# The spi_imx module does not seem to be required by the ALSA one.
modprobe snd-imx-alsa-tsc2102
# wait for the creation of all nodes
sleep 2
# give permissions of the sound device to the audio group
chown root:audio /dev/snd/*
eof
chmod a+x /etc/init.d/S60alsa
After reboot, you should be able to play audio files as guest user.