Skip to content

Instantly share code, notes, and snippets.

@nicksergeant
Created June 25, 2025 14:55
Show Gist options
  • Save nicksergeant/5ca762be64c75fdf16e57b90bbb8c2b9 to your computer and use it in GitHub Desktop.
Save nicksergeant/5ca762be64c75fdf16e57b90bbb8c2b9 to your computer and use it in GitHub Desktop.
AppleScript for arranging windows how I want them
on resize_app_window(app_name, win_position, win_size)
if application app_name is running then
tell application "System Events" to tell process app_name
set position of (every window) to {item 1 of win_position, item 2 of win_position}
set size of (every window) to {item 1 of win_size, item 2 of win_size}
end tell
end if
end resize_app_window
on run argv
set screen_width to item 1 of argv
set screen_height to item 2 of argv
set max_laptop_width to 1800
set min_widescreen_width to 3400
set padding to 16
if screen_width > max_laptop_width then
# Monitor+
set position_top to 30 + padding
set full_height to screen_height - position_top - padding
else
# Laptop
set position_top to 39 + padding # Account for The Notch.
set full_height to screen_height - position_top - padding
end if
set one_third_height to full_height * 0.35
set half_height to full_height / 2
set two_thirds_height to full_height * 0.65
if screen_width > min_widescreen_width then
# Widescreen+
set center_width to screen_width * 0.46
set bottom_left_position to {padding, screen_height - one_third_height}
set bottom_left_size to {(screen_width - center_width) / 2 - padding - padding, one_third_height - padding}
set thin_left_size to {600, two_thirds_height}
else if screen_width > max_laptop_width and screen_width < min_widescreen_width then
# Monitor
set center_width to screen_width * 0.6
set bottom_left_position to {padding, screen_height - one_third_height}
set bottom_left_size to {600, one_third_height - padding}
set thin_left_size to {600, two_thirds_height}
else
# Laptop
set center_width to screen_width - (padding * 2)
set half_width to center_width / 2
set bottom_left_position to {padding, screen_height - half_height - 1}
set bottom_left_size to {half_width - 9, half_height - padding}
set thin_left_size to {600, full_height}
end if
set center_position to {(screen_width - center_width) / 2, position_top}
set center_size to {center_width, full_height}
set narrow_half_size to {center_width, two_thirds_height}
set thin_left_position to {padding, position_top}
resize_app_window("1Password", center_position, center_size)
resize_app_window("Chromium", center_position, center_size)
resize_app_window("Linear", center_position, center_size)
resize_app_window("Fantastical", center_position, center_size)
resize_app_window("Missive", center_position, center_size)
resize_app_window("Mimestream", center_position, center_size)
resize_app_window("Music", center_position, center_size)
resize_app_window("NetNewsWire", center_position, center_size)
resize_app_window("Photos", center_position, center_size)
resize_app_window("Pixelmator Pro", center_position, center_size)
resize_app_window("RadarScope", center_position, center_size)
resize_app_window("Raycast", center_position, center_size)
resize_app_window("Reflect", center_position, center_size)
resize_app_window("Safari", center_position, center_size)
resize_app_window("Weather", center_position, center_size)
resize_app_window("zoom.us", center_position, narrow_half_size)
resize_app_window("Finder", bottom_left_position, bottom_left_size)
resize_app_window("TextEdit", bottom_left_position, bottom_left_size)
resize_app_window("Ivory", thin_left_position, thin_left_size)
resize_app_window("Messages", thin_left_position, thin_left_size)
if screen_width > min_widescreen_width then
# Widescreen
resize_app_window("Slack", center_position, narrow_half_size)
resize_app_window("Things", center_position, narrow_half_size)
else if screen_width > max_laptop_width and screen_width < min_widescreen_width then
# Monitor
resize_app_window("Slack", center_position, narrow_half_size)
resize_app_window("Things", center_position, narrow_half_size)
else
# Laptop
resize_app_window("Slack", center_position, center_size)
resize_app_window("Things", center_position, center_size)
end if
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment