LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-16-2008, 01:58 PM   #1
edgjerp
Member
 
Registered: Dec 2004
Location: Trondheim, Norway
Distribution: kubuntu 10.04
Posts: 308

Rep: Reputation: 31
usb speakers as default


I have a set of usb speakers for my laptop. when I play music using audacious, (and other gui players) I can change settings to send the music through them.

but for waking up in the morning I have a script that calls mplayer to play a random song from my library. I have not figured out how to make the system use the usb speakers for default system wide.
 
Old 06-17-2008, 08:20 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Plug in your USB speakers. Now
cat /proc/asound/cards
You'll see something like this:
Code:
tred@vaio:~$ cat /proc/asound/cards
 0 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0x80000000 irq 16
 1 [Audio          ]: USB-Audio - Bose USB Audio
                      Bose Corporation Bose USB Audio at usb-0000:00:1d.2-1, full speed
tred@vaio:~$
So I can see my USB speakers are at [1]
As root do the following:
Code:
cp /usr/share/alsa/alsa.conf  /usr/share/alsa/alsa.conf.orig
Now, still as root, edit the file /usr/share/alsa/alsa.conf and find this bit:

Code:
# defaults

defaults.ctl.card 0
defaults.pcm.card 0
Change the 0's to 1's
Save the file
Still as root, do
Code:
cp /usr/share/alsa/alsa.conf  /usr/share/alsa/alsa.conf.USB
Restart the sound system,
Code:
sudo /etc/init.d/alsa-utils restart
And your USB speakers will be working.

I made an ugly hack, so that if the PC boots with the USB speakers plugged in, it uses them, otherwise, it uses the internal soundcard (Intel, in my case)
So I put this code at the end of /etc/rc.local
Code:
# Simple control of Bose USB speakers
# If they are plugged in at boot, they'll be used,
# otherwise the internal soundcard will be used
#
# It may fail if anything is using the sound card when it is called

foo=$(cat /proc/asound/cards | grep Bose)
if [ "$foo" != "" ] ;  then 
# Use USB speakers
# echo Bose USB speakers detected >> /var/log/messages
cp /usr/share/alsa/alsa.conf.USB /usr/share/alsa/alsa.conf
/etc/init.d/alsa-utils restart
# BUT realplay defaults to using /dev/dsp, and doesn't know to use
# /dev/dsp1, so we need a another hack:
rm /dev/dsp
ln -sT  /dev/dsp1 /dev/dsp;
else
# Use the original conf file
# echo No Bose USB speakers detected >> /var/log/messages
cp /usr/share/alsa/alsa.conf.orig  /usr/share/alsa/alsa.conf
/etc/init.d/alsa-utils restart
fi
exit 0
I would have liked to do something clever with udev rules, so that when the USB speakers were plugged it, they were selected and configured automatically, and unselected when unplugged, but it got too complicated for my tiny brain, and I resorted to the above, which works fine

Anyone out there good with udev rules?
 
1 members found this post helpful.
Old 06-17-2008, 12:11 PM   #3
edgjerp
Member
 
Registered: Dec 2004
Location: Trondheim, Norway
Distribution: kubuntu 10.04
Posts: 308

Original Poster
Rep: Reputation: 31
thanks! now my script-launched mplayer uses the usb speakers.
 
Old 06-26-2008, 02:12 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Quote:
now my script-launched mplayer uses the usb speakers.
But I have discovered that this may not work always.
Please see this thread for a more robust script:
http://www.linuxquestions.org/questi...0/#post3196077
You'll have to adapt it a bit to recognise your USB soundcard's unique identifier, but this should be easy once you have read the post.
 
Old 02-16-2013, 04:28 PM   #5
Naimbora
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Rep: Reputation: Disabled
Hi,

Iwas just following the steps but Idont have the alsa-utils file in the directory /etc/init.d/ . I only have alsa-restore and alsa-store files. How can restart the sound system?

Cheers!
 
Old 02-17-2013, 04:12 AM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Welcome to LQ!

This thread is over 4 years old, and many things have changed with linux since then, including the way sound cards are handled.

So, please start a new thread with the details of your problem.

Also, it is important for you to tell us the linux distribution you are using (eg "Mint 14" or "Fedora 18"), because the different distributions sometimes handle things very differently.
 
  


Reply


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
I need help with my USB Speakers Delicate_Shadow Linux - Hardware 2 08-23-2006 03:39 PM
USB based speakers alnet Fedora 3 06-02-2006 10:57 AM
USB Speakers Help Delicate_Shadow Linux - Hardware 0 05-10-2006 02:50 PM
Will USB Speakers work? weijie90 Linux - Hardware 1 04-21-2006 06:08 AM
sound with usb speakers pomelo Linux - Hardware 6 02-04-2006 03:50 PM


All times are GMT -5. The time now is 03:13 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration