Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to change sound output device' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to change sound output device
Authored by: bnaro on Feb 11, '10 07:48:06PM
The command-line SwitchAudioSource is great! Thanks! I wanted to alternate between Line-Out and Headphones with the middle click of my Mighty Mouse. So, I saved the following script as an application (it's messy, beware):

tell application "GrowlHelperApp"
	set the allNotificationsList to 
		{"Audio Output Source"}
	set the enabledNotificationsList to 
		{"Audio Output Source"}
	
	register as application 
		"Audio Output Source" all notifications allNotificationsList 
		default notifications enabledNotificationsList 
		icon of application "Script Editor"
	
	set CURRENT to do shell script "SwitchAudioSource -c"
	if CURRENT is "Built-in Line Output" then
		do shell script "SwitchAudioSource -s 'Built-in Output'"
		--	Send a Notification...
		notify with name 
			"Audio Output Source" title 
			"Audio Output Source" description 
			"Headphones enabled" application name "Audio Output Source"
		
	else if CURRENT is "Built-in Output" then
		do shell script "SwitchAudioSource -s 'Built-in Line Output'"
		--	Send a Notification...
		notify with name 
			"Audio Output Source" title 
			"Audio Output Source" description 
			"Line-Out enabled" application name "Audio Output Source"
		
	end if
	
	
end tell
and then through system prefs assigned the middle click to launch the application. Hope it helps someone.
Edited on Feb 11, '10 07:49:20PM by bnaro


[ Reply to This | # ]
An AppleScript to change sound output device
Authored by: bnaro on Feb 12, '10 06:24:41AM

Forgot to add: I'm using growl to notify the switch. So...you'll need that.



[ Reply to This | # ]