Jump to content

Next Audio Output Device + request for help!


Recommended Posts

Posted

This is absolutely possible - You'll just need to use a Script Filter as your first item instead of Keyword, and then write a script to grab which is the active output and print the appropriate XML to display the info in the subtitle.

 

See the following thread for details on passing feedback back to Alfred:

http://www.alfredforum.com/index.php?/topic/5-generating-feedback-in-workflows/

 

Also, take a look at Mikegrb's Audio Device Selection workflow, which will likely do what you want already.

http://mikegrb.com/2013/01/18/alfred2-audio-device/

Posted

Seems to work well for me, nice job. My only suggestion would be to maybe list the "next device" in the subtitle output, so the user knows what it's going to switch to.

 

Something like:

 

"Current Device: Built-In Output, Next Device: Music Streamer II"

Posted

I had a go at doing that but my knowledge of Ruby is not good enough. The SwitchAudioSource CLI only gives you a list of available output devices, so I would need to compare that with the next output device to find the current output device.

 

Unless you fancy having a go?

Posted

I don't know Ruby at all, but it shouldn't be too difficult.

 

Looking at the documentation:

 

"SwitchAudioSource -c" shows the current device

"SwitchAudioSource -a" shows all devices

 

Assuming the -n flag just chooses the next device in that list, you could easily just load the names generated by "-a" into an array. Then it's just a simple compare to find which array index matches the current device, say "n", and then print "n+1" as the next device.

Posted

-a outputs more along the lines of:

Built-in Microphone (input)
Built-in Output (output)
AirPlay (output)

Whereas -n outputs just:

AirPlay

… for example. I would need to trim the " (output)".

 

If you could provide an example of how to do this, it would be appreciated. My knowledge of Ruby sucks (I never code in Ruby!).

 

Edit: just seen you don't know Ruby either. I'll ask on IRC :P

Posted

I'm sure there's a more appropriate "Ruby" way of doing this with regular expressions, but here it is with sed:

 

 

kair:Desktop dave$ ./SwitchAudioSource -a | grep "(output)" | sed 's/ (output)$//'
Built-in Output
Music Streamer II

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...