Skip to content

Instantly share code, notes, and snippets.

@farfanoide
Last active August 29, 2015 14:01
Show Gist options
  • Save farfanoide/e5c8f4eec5218c1dc043 to your computer and use it in GitHub Desktop.
Save farfanoide/e5c8f4eec5218c1dc043 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
# Little script to select output source from cli.
# SwitchAudioSource must be in your PATH
# https://code.google.com/p/switchaudio-osx/
if ARGV.empty?
sources = `SwitchAudioSource -a | grep -i output`.split "\n"
sources.each_with_index { |source, index| puts "#{index}) #{source}" }
option = gets
audio = sources[option.to_i].sub(' (output)','')
else
option = ARGV[0]
case option
when '1'
audio = 'Built-in Output'
when '2'
audio = 'Saffire 6USB2.0'
when '3'
audio = 'HDMI'
else
puts 'opcion invalida'
audio = 'nada che'
end
end
`SwitchAudioSource -t output -s "#{audio}"` unless audio == 'nada che'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment