Created
January 19, 2017 15:24
-
-
Save Daij-Djan/730cc9ef36e165875ae8c81e4835da8c to your computer and use it in GitHub Desktop.
Run a local Webserver with Sinatra that can do actions on your Mac. I mainly want /quiet for my hacked amazon dash button And/Or home control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'sinatra' | |
get '/hello' do | |
value = `osascript -e 'tell app "System Events" to display dialog "Hello"'` | |
end | |
get '/lock' do | |
value = `"/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession" -suspend` | |
end | |
get '/quiet' do | |
value = `osascript -e 'tell application "iTunes" to pause'` | |
value = `osascript -e 'tell application "System Events" to tell process "iTunes" to set visible to false'` | |
value = `osascript -e 'tell application "Spotify" to pause'` | |
value = `osascript -e 'tell application "System Events" to tell process "Spotify" to set visible to false'` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run it in the terminal: terminal isn't sandboxed ;) it (obviously) doesn't work if run in a sandbox