LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

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


Hi,

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.

Code:
HDMI
pcm "hw:1,3"

Analog
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.

Thanks,
4dplane

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 09:38 PM.
 
Old 07-21-2009, 03:32 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
I'm not good in bash scripting, but you can use "case" in a script like this:
Code:
#!/bin/sh

case $* in

HDMI )
/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
;;
esac

source ~/.asoundrc
You can use it, like "script.sh HDMI", or "script.sh 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 03:35 AM.
 
Old 07-21-2009, 08:30 AM   #3
tredegar
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
Code:
/etc/init.d/alsa-utils restart
This worked for me, when I had a similar situation.
 
  


Reply

Tags
alsa, asoundrc, sound



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 10:12 PM
Tomcat reload servlet is very slow, but reload jsp is fast and good? gsbarry Programming 2 04-28-2006 09:34 PM
asoundrc for soundcard with more than one devices eidimon Linux - Hardware 0 03-26-2006 09:25 AM
Asoundrc problems Atmchicago Linux - Games 4 04-11-2005 03:19 PM
What needs adding to .asoundrc to get 5.1? redneon Linux - Software 0 01-31-2005 08:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:16 AM.

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