Skip to content

Instantly share code, notes, and snippets.

@othercat
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save othercat/1cd2b3c4b17c18f55efd to your computer and use it in GitHub Desktop.

Select an option

Save othercat/1cd2b3c4b17c18f55efd to your computer and use it in GitHub Desktop.
Create a new window of Safari when staying in a new Space
set found to 0
set resolution_wide to 1440
tell application "System Events"
repeat with i from 1 to (count of window of process "Safari")
set bnds to bounds of window i of application "Safari"
set wide to item 3 of bnds
if wide < resolution_wide then
set found to 1
end if
end repeat
set found to count of window of process "Safari"
end tell
tell application "Safari"
if found is 0 then
make new document
else
set miniaturized of windows to false
end if
activate
end tell
@othercat
Copy link
Copy Markdown
Author

fix an issue that multiple monitors will cause window counting error. need to adjust the width of internal display manually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment