Last active
September 6, 2018 23:59
-
-
Save prodrammer/6e97c6d31c8887dea83d8275bf7b160a to your computer and use it in GitHub Desktop.
Changes resolution when sharing during a ZOOM.us meeting.
This file contains hidden or 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
on main() | |
set hugeMonitor to "LG ULTRAWIDE" -- set to name shown at top of displays system prefs applet | |
set debigulateIndex to 2 -- set to 1-based index of preferred "scaled" size from displays system prefs applet | |
set debigulateWidth to 2560 -- set to width of preferred "scaled" size from displays system prefs applet | |
set debigulateHeight to 1100 -- set to height of preferred "scaled" size from displays system prefs applet | |
set embiggenWidth to 3840 -- set to width of "default for display" size from displays system prefs applet | |
set embiggenHeight to 1600 -- set to height of "default for display" size from displays system prefs applet | |
tell current application | |
tell application "System Events" | |
repeat while true | |
if not (exists (window "Sharing Frame Window" of application process "zoom.us")) then | |
repeat until exists window "Sharing Frame Window" of application process "zoom.us" | |
delay 1 | |
end repeat | |
tell application "Finder" to set {desktopX, desktopY, desktopWidth, desktopHeight} to bounds of window of desktop | |
if desktopWidth > debigulateWidth or desktopHeight > debigulateHeight then | |
display notification "ZOOM sharing started. Debigulating your monitor." | |
my change_resolution(hugeMonitor, debigulateIndex) | |
end if | |
end if | |
repeat while exists window "Sharing Frame Window" of application process "zoom.us" | |
delay 1 | |
end repeat | |
tell application "Finder" to set {desktopX, desktopY, desktopWidth, desktopHeight} to bounds of window of desktop | |
if desktopWidth < embiggenWidth or desktopHeight < embiggenHeight then | |
display notification "ZOOM sharing stopped. Embiggening your monitor." | |
my set_default_resolution(hugeMonitor) | |
end if | |
end repeat | |
end tell | |
end tell | |
end main | |
on open_displays() | |
tell application "System Preferences" | |
activate | |
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays" | |
delay 1 | |
end tell | |
end open_displays | |
on close_displays() | |
tell application "System Preferences" | |
quit | |
end tell | |
end close_displays | |
on set_default_resolution(monitorName) | |
my open_displays() | |
tell application "System Events" | |
tell application process "System Preferences" | |
set frontmost to true | |
tell tab group 1 of window monitorName | |
click radio button "Default for display" of radio group 1 | |
end tell | |
end tell | |
end tell | |
my close_displays() | |
end set_default_resolution | |
on change_resolution(monitorName, resolutionButtonIndex) | |
my open_displays() | |
tell application "System Events" | |
tell application process "System Preferences" | |
set frontmost to true | |
tell tab group 1 of window monitorName | |
click radio button "Scaled" of radio group 1 | |
click radio button resolutionButtonIndex of radio group 1 of group 1 | |
end tell | |
end tell | |
end tell | |
my close_displays() | |
end change_resolution | |
my main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment