Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby code using rb-appscript to reset Twitter's preferences in Spaces since Twitter doesn't work very well with OSX Spaces.
require "rubygems"
require "appscript"
include Appscript
class SystemEvents
def initialize( &block )
@app = app( "System Events" )
launch
instance_eval &block
quit
end
def launch
@was_running = @app.is_running?
@app.launch if not @was_running
end
def quit
@app.quit if not @was_running
end
def remove_space_binding( app_id )
bindings = @app.expose_preferences.spaces_preferences.application_bindings.get
bindings.delete( app_id )
@app.expose_preferences.spaces_preferences.application_bindings.set( :to => bindings )
end
def add_space_binding( app_id, space_number )
bindings = @app.expose_preferences.spaces_preferences.application_bindings.get
bindings[ app_id ] = space_number
@app.expose_preferences.spaces_preferences.application_bindings.set( :to => bindings )
end
end
SystemEvents.new do
twitter_id = "com.twitter.twitter-mac"
remove_space_binding twitter_id
print "Unbound Twitter from Spaces\n"
add_space_binding twitter_id, 4
print "Bound Twitter to Space 4\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment