Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-20-2009, 09:29 PM   #1
Registered: Sep 2003
Distribution: Debian
Posts: 69

Rep: Reputation: 15
Arrow reload .asoundrc without logging out and in


my Ubuntu setup will be used by multiple people and at different places and some people will want to use HDMI audio and other will wan to use the 1/8 inch audio jack(analog). All of my sound is working except I have to change this line of my .asoundrc to switch to either HDMI or analog.

pcm "hw:1,3"

pcm "hw:0,0"
So I am looking to set up a script that I can call from a button that will use different .asoundrc files or an .asoundrc file that has a conditional in it that switches the output. How can this be done? Can the .asound file use conditionals like "if" and how can I tell Linux to re-read the updated .asoundrc file.


O' by the way, all of this is being run with Fluxbox but I don't think that will make a difference.

Last edited by waffe; 07-20-2009 at 10:38 PM.
Old 07-21-2009, 04:32 AM   #2
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,154
Blog Entries: 1

Rep: Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019
I'm not good in bash scripting, but you can use "case" in a script like this:

case $* in

/usr/bin/sed -i 's/pcm \"hw\:0\,0\"/pcm \"hw\:1\,3\"/g' ~/.asoundrc

Analog )
/usr/bin/sed -i 's/pcm "\hw\:1\,3\"/pcm \"hw\:0\,0\"/g' ~/.asoundrc

source ~/.asoundrc
You can use it, like " HDMI", or " Analog" to change the pcm line of .asoundrc.
The last command (source) is used when you want to re-read settings from a config file like .asoundrc

Last edited by bathory; 07-21-2009 at 04:35 AM.
Old 07-21-2009, 09:30 AM   #3
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
You might like to take a look at this thread, especially post #8

Once you have changed alsa.conf you'll need (as root) to do
/etc/init.d/alsa-utils restart
This worked for me, when I had a similar situation.


alsa, asoundrc, sound

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
asoundrc and SB Live 7.1 unq Linux - Hardware 1 02-06-2007 11:12 PM
Tomcat reload servlet is very slow, but reload jsp is fast and good? gsbarry Programming 2 04-28-2006 10:34 PM
asoundrc for soundcard with more than one devices eidimon Linux - Hardware 0 03-26-2006 10:25 AM
Asoundrc problems Atmchicago Linux - Games 4 04-11-2005 04:19 PM
What needs adding to .asoundrc to get 5.1? redneon Linux - Software 0 01-31-2005 09:33 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration