tags:

views:

229

answers:

3

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?

+1  A: 

the screensaver in Mac is just an application, so possibly you could check if the process is running...

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

Fortega
+1  A: 

My Mac is at home and I'm not, so I can't test this solution, but how about something like:

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

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

shoover
A: 

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
Dmitry