Register
It is currently Sat Apr 19, 2014 3:25 am

Sound Output Switcher


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun Jun 15, 2008 11:16 pm   

Joined: Wed Feb 20, 2008 4:44 pm
Posts: 4
Location: /dev/null
This is my first post here at bashscripts.org, I have been looking around the site for awhile, and have been meaning to get some of my personal scripts up, I have some more, I just need to get around to posting them. Let me know what you think of this one.

This is a simple script I wrote to turn on/off the sound output to my headset and surround sound. I wrote it because I got sick of turning my surround sound unit off to use headsets, and music playing on headsets when surround sound is in use. It should work for anyone, but it may require some tweaking, PM me if you need any help with getting it to work for you. Also this is a more complex version compared to the original, I can post the original aswell, I added arrays and loops to this one.


Code:
#!/bin/bash
#todo: ----
#make it toggle
#
#Usage ./$0 [options]
#    -h will play the output on the headset
#    -s will play the output on the surround sound

#An Array holding the three values of my surround sound output for amixer.
surround=(Surround Center Side)
surround_cnt=${#surround[*]}

#evaluate command line arguments.
while [ $# -gt 0 ]
do
        case "$1" in
                "-s")
                        #mute the headset output
                        amixer -c 0 sset Front mute > /dev/null

                        #unmute the surround sound outputs.
                        for ((i=0;i<$surround_cnt;i++))
                        do
                                amixer -c 0 sset ${surround[$i]} unmute > /dev/null
                        done
                ;;
                "-h")
                        #unmute the headset output
                        amixer -c 0 sset Front unmute > /dev/null

                        #mute the surround sound outputs.
                        for ((i=0;i<$surround_cnt;i++))
                        do
                                amixer -c 0 sset ${surround[$i]} mute > /dev/null
                        done
                ;;
        esac
        shift
done


Top
 Profile  
 PostPosted: Wed Jun 18, 2008 9:12 am   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
very nice... welcome to bashscripts.org!


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP