The sonos
gem uses the savon
gem for SOAP communication with the Sonos api. Savon
was logging to stdout
and that was preventing Alfred workflows from working (they depend on stdout
to communicate). My fork of the sonos gem disables the logging and can be used in your Alfred workflow.
require '/path/to/sonos'
Sonos.savon_config = { log: false }
speaker = Sonos::System.new.speakers.first
puts case "{query}"
when "play" then speaker.play and "Playing"
when "pause" then speaker.pause and "Paused"
when "up" then speaker.volume += 5 and "Turned up"
when "down" then speaker.volume -= 5 and "Turned down"
when "next" then speaker.next and "Next"
else "Unknown command"
end