Ian McNally

Sleep display from the command line

June 11, 2014

I like putting my display to sleep when I walk away from the computer. It saves energy, prompts for a password on return and is faster than waking the machine from sleep.

To make the sleeping process faster, I wanted to make an Alfred workflow. The workflow would just run a command in Terminal. The problem? Until OS X 10.9, there was no such command, and now there is!

pmset displaysleepnow

Wham, bam, thank you Mavericks!

Here’s what the workflow looks like:


Or, to create it

  1. Click + (bottom left) to create a workflow

  2. Inside the new workflow, click + (top right) then Triggers > Hotkey.

  3. Enter a keyword. I like dsleep.

  4. Click + to add an Action. Choose Run Script.

  5. Inside the script’s text field, add pmset displaysleepnow.

  6. Enjoy.

Ian McNally

Hey, I'm Ian. I build websites and write about what I learn as I go. Follow me on Twitter.