Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created June 24, 2011 16:48
Show Gist options
  • Save rubysolo/1045183 to your computer and use it in GitHub Desktop.
Save rubysolo/1045183 to your computer and use it in GitHub Desktop.
A Mac OS application resizer script for different desktop resolutions.
require "rubygems"
require "appscript"
class AppResizer
include Appscript
# Full screen bounds for all modes.
HOME_FULL_SCREEN = [0, 0, 2560, 1440]
LAPTOP_FULL_SCREEN = [0, 0, 1440, 900]
# Configure required applications.
def initialize
@pathfinder = app "Path Finder"
@firefox = app "Firefox"
@chrome = app "Google Chrome"
@safari = app "Safari"
@textmate = app "TextMate"
@iterm = app "iTerm"
@omnifocus = app "OmniFocus"
@skype = app "Skype"
@snagit = app "Snagit"
end
# Resizes application for given window and bounds.
# ==== Parameters
# * +application+ - Required. The application to resize.
# * +window+ - Required. The application window to resize.
# * +bounds+ - Required. The screen bounds for which to resize. Format: [start_x, start_y, end_x, end_y]
def resize application, window, bounds
if application && window && bounds
application.windows[window].bounds.set(bounds) if application.is_running?
end
end
# Resizes applications for home office screen.
def home
resize @pathfinder, 2, [1300, 0, 2560, 900]
resize @firefox, 1, [0, 0, 1342, 1068]
resize @chrome, 1, [0, 0, 1342, 1068]
resize @safari, 1, [0, 0, 1342, 1068]
resize @textmate, 1, [1342, 0, 2560, 1068]
resize @iterm, 1, [0, 1068, 2560, 1440]
resize @omnifocus, 1, [0, 600, 1150, 1440]
resize @skype, 1, [0, 0, 600, 800]
resize @snagit, 1, [0, 0, 1300, 1000]
end
# Resizes applications for laptop screen.
def laptop
resize @pathfinder, 2, LAPTOP_FULL_SCREEN
resize @firefox, 1, LAPTOP_FULL_SCREEN
resize @chrome, 1, LAPTOP_FULL_SCREEN
resize @safari, 1, LAPTOP_FULL_SCREEN
resize @textmate, 1, LAPTOP_FULL_SCREEN
resize @iterm, 1, [0, 300, 1440, 900]
resize @omnifocus, 1, [0, 0, 1174, 1440]
resize @skype, 1, [0, 0, 600, 900]
resize @snagit, 1, [0, 0, 1200, 900]
end
def self.run mode = "home"
AppResizer.new.send mode
end
end
# Run
AppResizer.run ARGV[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment