brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pmset displaysleepnow turns off your Mac screen from the terminal

Terminal
~/tips/tip-terminal-pmset-displaysleepnow

pmset displaysleepnow

Turns the display off right away while everything keeps running.

A long download or render is running and the bright screen is just in the way. You can switch the display off without putting the Mac to sleep.

One command, no sudo needed:

pmset displaysleepnow

The screen goes dark at once. Apps, downloads and ssh sessions carry on, because only the display sleeps. Move the mouse or press a key to wake it.

It is nice at the end of a chain. I like it combined with caffeinate, so the Mac itself stays awake for a job while the screen goes dark:

caffeinate -i ./render.sh &
pmset displaysleepnow

The bigger brother is pmset sleepnow, which sleeps the whole machine and stops whatever is running, so don’t mix them up in a script.

Depending on your settings, waking the display may ask for your password, because the screen lock follows display sleep. That is set under Lock Screen in System Settings, with the option to require a password after the screen turns off.

Further reading: pmset man page (macOS)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link