Check if the screensaver is active using the Mac Bash Script command

I found many useful Bash commands that can execute OS X behavior from the command line, for example:

screencapture -x -C $FILENAME

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

+4
source share
3 answers

I use this:

 ps ax|grep [S]creenSaverEngine > /dev/null if [ "$?" != "0" ] ; then # screen saver is not active else # screen saver is active fi 
+8
source

The screensaver on Mac is just an application, so maybe you can check if the process is running ...

I think the process is called "ScreenSaverEngine", but I'm not sure if this is true for the version you have :)

+2
source

My Mac is at home and I am not, so I can’t check this solution, but what about something like:

 ps -ef | grep [s]creencapture > nul; echo $? 

The brackets [] prevent grep from matching this grep command, allowing it to match all other commands containing "screencapture". (Assuming "screencapture" is the name of the process you are trying to detect.)

+1
source

All Articles