Reputation: 45622
Is there a way to start the screensaver (and lock the screen) from a bash script?
Upvotes: 48
Views: 24847
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
Reputation: 89
on macOS Monterey, run in terminal:
open -b com.apple.ScreenSaver.Engine
Upvotes: 7
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