Last active
April 20, 2018 17:40
-
-
Save yspreen/54d795ba89fc5b669423b54d2c4ef12b to your computer and use it in GitHub Desktop.
Fix Chrome Zoom behaviour with Applescript
This file contains 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
-- Fix Chrome Zoom by yspreen | |
set dock_left to 1 -- Specify your dock position here! | |
set dock_bottom to 0 -- Specify your dock position here! | |
set dock_right to 0 -- Specify your dock position here! | |
set menu_bar_height to 22 -- change this! | |
-- Retina MacBooks probably have higher values. | |
-- Maximize Chrome, then run this script in the editor to see the output: | |
-- (*If chrome is currently in full-screen, your menu-bar height is:*) | |
-- (*22*) | |
set is_fullscreen to 0 | |
set do_log to 1 | |
tell application "Finder" | |
set desktop_size to bounds of window of desktop | |
set screen_width to item 3 of desktop_size | |
set screen_height to item 4 of desktop_size | |
end tell | |
repeat | |
tell application "System Events" | |
if application process "Google Chrome" exists then | |
tell application "Google Chrome" | |
set chrome_bounds to bounds of front window | |
if do_log = 1 then | |
log "If chrome is currently in full-screen, your menu-bar height is:" | |
log item 2 of chrome_bounds | |
set do_log to 0 | |
end if | |
end tell | |
tell application "System Events" to tell process "Dock" | |
set dock_dimensions to size in list 1 | |
set dock_width to item 1 of dock_dimensions | |
set dock_height to item 2 of dock_dimensions | |
set item 2 of desktop_size to menu_bar_height | |
if dock_left = 1 then | |
set item 1 of desktop_size to dock_width | |
end if | |
if dock_bottom = 1 then | |
set item 4 of desktop_size to screen_height - dock_height | |
end if | |
if dock_right = 1 then | |
set item 3 of desktop_size to screen_width - dock_width | |
end if | |
end tell | |
if (item 2 of chrome_bounds = item 2 of desktop_size) and (item 4 of chrome_bounds = item 4 of desktop_size) then | |
if is_fullscreen = 0 then -- changed to fs | |
tell application "Google Chrome" | |
set bounds of front window to desktop_size | |
end tell | |
end if | |
set is_fullscreen to 1 | |
else | |
set is_fullscreen to 0 | |
end if | |
end if | |
end tell | |
delay 0.5 | |
end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment