Skip to content

Instantly share code, notes, and snippets.

@nriley
Created January 26, 2020 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nriley/5bf04f38862a5e55eca26cfd70e6d4eb to your computer and use it in GitHub Desktop.
Save nriley/5bf04f38862a5e55eca26cfd70e6d4eb to your computer and use it in GitHub Desktop.
Fix Catalina Finder windows that sprout unwanted toolbars
-- Fix Catalina Finder windows that sprout unwanted toolbars
-- Takes advantage of the property that these windows cannot have their toolbars hidden through AppleScript
-- Nicholas Riley <nriley@sabi.net>
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Finder"
set _windows to Finder windows
repeat with _window in _windows
tell _window
if its toolbar visible then
set _bounds to its bounds
set its toolbar visible to false
if its toolbar visible then
-- log "broken: " & its name
activate
tell application "System Events"
repeat while not (exists (menu item "Show Toolbar" of menu "View" of menu bar 1 of application process "Finder"))
click menu item "Hide Toolbar" of menu "View" of menu bar 1 of application process "Finder"
delay 0.1
end repeat
end tell
else
-- not broken but the toolbar is inappropriately hidden
-- so, work around another Finder bug in which the window size shrinks every time you hide and show the toolbar
-- set AppleScript's text item delimiters to ", "
set _oldBounds to its bounds
-- log (its bounds) as string
set its toolbar visible to true
repeat while its bounds ≠ _oldBounds
-- wait for animation to complete
set _oldBounds to its bounds
-- log _oldBounds as string
delay 0.1
end repeat
set its bounds to _bounds
end if
end if
end tell
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment