5

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?

Chris Redford
  • 16,982
  • 21
  • 89
  • 109

3 Answers3

12

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 Ulupov
  • 311
  • 2
  • 4
2

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
  • 19,463
  • 14
  • 75
  • 113
1

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
  • 3,071
  • 1
  • 29
  • 40