dan
dan

Reputation: 45622

how can i start the screensaver (and lock the screen) from the os x terminal?

Is there a way to start the screensaver (and lock the screen) from a bash script?

Upvotes: 48

Views: 24847

Answers (3)

yurymik
yurymik

Reputation: 2224

Have you tried this?

/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine

Update for macOS High Sierra:

/System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine

Update for macOS Sonoma:

open /System/Library/CoreServices/ScreenSaverEngine.app

Upvotes: 56

Yurii Samoienko
Yurii Samoienko

Reputation: 89

on macOS Monterey, run in terminal:

open -b com.apple.ScreenSaver.Engine

Upvotes: 7

rouble
rouble

Reputation: 18181

Here is a bash script that does exactly what you are asking for: maclock

It is called from the command line as follows:

maclock

Under the covers it calls:

open -a ScreenSaverEngine

It can also be used to mute the system, or put the display to sleep:

maclock --mute --display

Upvotes: 18

Related Questions