How to Make Your Mac Sleep

This article shows how to put your Mac to sleep using a variety of methods. We will walk through how to make your Mac sleep using AppleScript, Automator, and the command line.

This article shows how to put your Mac to sleep using a variety of methods. We will walk through how to make your Mac sleep using AppleScript, Automator, and the command line.

Sleep via AppleScript

You can ask the application Finder to put the Mac to sleep on your behalf. The following snippet works on Mac OS X 10.4 through to Mac OS X 10.7:

tell the application "Finder" to sleep

An AppleScript to make your Mac sleep

The Mac will sleep immediately when this AppleScript is run.

Sleep via Automator

Automator does not include a built-in action for making your Mac sleep. We are going to create one using the Run AppleScript action.

  1. Create a new workflow in Automator.

    Create a new workflow in Automator

  2. Find and add the Run AppleScript action.

  3. Copy and paste the following AppleScript into the action:

    tell the application "Finder" to sleep
    

    Add an AppleScript action to make your Mac sleep

  4. Save your workflow.

When this Automator workflow is run, your Mac will sleep immediately.

Sleep via the Command Line

The easiest way to make your Mac sleep using the command line is with the following:

osascript -e 'tell application "Finder" to sleep'

Terminal command to make your Mac sleep

When issued, this command will immediately put your Mac to sleep.

The Common Theme

You may have noticed all the methods above use a little bit of AppleScript. AppleScript lets you talk to savvy applications in a near English dialect. Different applications can perform different tasks for you, and with AppleScript you can chain these tasks together in powerful ways.