Skip to content

Instantly share code, notes, and snippets.

@matsimitsu
Created July 9, 2016 20:55
Show Gist options
  • Select an option

  • Save matsimitsu/72f42328d115f9b05488574f5adfe2bd to your computer and use it in GitHub Desktop.

Select an option

Save matsimitsu/72f42328d115f9b05488574f5adfe2bd to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'mqtt'
MQTT::Client.connect('192.168.0.20') do |client|
client.subscribe('components/plex/on', 'components/plex/off')
client.get do |topic,message|
case topic
when 'components/plex/on' then `open -a /Applications/Plex.app`
when 'components/plex/off' then `osascript -e 'quit app "Plex"'`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment