Skip to content

Instantly share code, notes, and snippets.

@moonhouse
Created August 21, 2013 12:58
Show Gist options
  • Select an option

  • Save moonhouse/6294141 to your computer and use it in GitHub Desktop.

Select an option

Save moonhouse/6294141 to your computer and use it in GitHub Desktop.
Automatically move Skype and Outlook windows when connecting my MacBook to an external screen with 1200x1600 pixel resolution.
require '/Applications/Zephyros.app/Contents/Resources/libs/zephyros.rb'
def dell_screen
API.all_screens.each do |screen|
frame = screen.frame_without_dock_or_menu
if frame.w == 1200 and frame.h == 1600
return screen
end
end
return false
end
def move_app_window(app_title)
API.running_apps.each do |app|
if app.title == app_title
return app.visible_windows.first
end
end
return nil
end
API.listen 'screens_changed' do
if screen = dell_screen
skype = move_app_window('Skype')
outlook = move_app_window('Microsoft Outlook')
frame = screen.frame_without_dock_or_menu
puts frame.h
frame.h = 800
skype.frame = frame
frame.y = 707
outlook.frame = frame
end
end
wait_on_callbacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment