Is it possible to set my Mac to hide all windows on waking up?

Whenever I wake my Mac up, it shows my workspace exactly how I left it. If I closed the lid while browsing my library on iTunes, for example, it will show that screen upon waking up, after I input my password.

Is there a way to change this default behavior? Once I close the lid, when I come back and input my password, I'd like to view the desktop. The apps shouldn't be quit or anything like that, just the windows should be hidden. You know, to start fresh, uncluttered.

(Similar to what this user is asking, but upon waking up instead of a keyboard combination.)

Is it possible? Maybe with some Apple Script or command line magic?


You have two options, maybe more 😅:

  1. Automator:

    • Make an Application document
    • Add the following action:

      Library -> Utilities -> Hide All Applications

    • Save the App

    • Add it to your login items

      System Preferences -> Users & Groups -> Choose your User -> Login Items

    • Voilà!, on next login all open apps will be hidden. Note that with this option, if the automator app have a window, that window will not hide, because this action is for Hide All Other apps

    Automator Hide All Apps

    1. AppleScript: You can use this script, i found it on LiveJournal:
tell application "System Events" to set all_apps to the name of every process whose visible is true

repeat with a in all_apps
    tell application a to try
        repeat with w in (get every window)
            set miniaturized of w to true
        end repeat
    on error
        activate
        tell application "System Events" to repeat (count windows of process a) times
            keystroke "m" using command down
            delay 0.1
        end repeat
    end try
end repeat

Similarly you need to make this script runs on start of your session, maybe you could make an App with Automator but instead using "Hide All Application" Action, you add "Run AppleScript" Action.

In both options, maybe some applications will not be hidden because at the time this runs, not all windows are yet opened.


If you're willing to use a commercial utility, Keyboard Maestro (which I swear by) has a "System Wake" macro trigger and a "Hide All Applications" action which would do the trick.