Skip to content

Instantly share code, notes, and snippets.

@geoffreywiseman
Created May 20, 2011 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoffreywiseman/982931 to your computer and use it in GitHub Desktop.
Save geoffreywiseman/982931 to your computer and use it in GitHub Desktop.
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