Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if Screensaver is Active using Mac Bash Script Command

Tags:

bash

macos

I've found many useful Bash commands that can execute OS X behaviors from the command line such as:

screencapture -x -C $FILENAME

Is there such a command that can check if the screen saver is active?

like image 794
Chris Redford Avatar asked Dec 03 '09 17:12

Chris Redford


People also ask

How do I trigger my Screen Saver on a Mac?

On your Mac, choose Apple menu > System Preferences, click Desktop & Screen Saver , then click Screen Saver. Click the “Show screen saver after” pop-up menu, then choose how long you want your Mac to wait before starting the screen saver when it's idle.

Does bash work on Mac terminal?

Mac OS X ShellsMac OS X comes with the Bourne Again SHell (bash) as the default user shell and also includes the TENEX C shell (tcsh), the Korn shell (ksh), and the Z shell (zsh). bash, ksh, and zsh are compatible with sh, the original Bourne shell.

Where are macOS screensavers stored?

These are located at "/System/Library/Screen Savers".


1 Answers

I am using this:

ps ax|grep [S]creenSaverEngine > /dev/null
if [ "$?" != "0" ] ; then
    # screen saver is not active
else
    # screen saver is active
fi
like image 182
Dmitry Ulupov Avatar answered Oct 22 '22 16:10

Dmitry Ulupov