Question

I'm trying to create an Alfred workflow to change the volume with hotkeys through Alfred.

A working gem to control Sonos is here:https://github.com/soffes/sonos

The problem is: including the gem as part of a script just plain doesn't work. When I run the workflow nothing happens. I've attached a screenshot of the Alfred screenshot I'm talking about.

I've tried other Ruby scripts and they run just fine. But anything that requires a gem doesn't work.

I've also tried downloading the gem and just requiring the absolute path, but no luck there, either.

Alfred screenshot

No correct solution

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top