Created
May 20, 2011 13:57
-
-
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.
This file contains 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
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