Remotely starting a screensaver

12 views
Skip to first unread message

Michael Wing

unread,
Oct 19, 2012, 10:26:54 AM10/19/12
to hq...@googlegroups.com

This may be the wrong place to ask this question, but it doesn't hurt to ask.  I'd like to remotely start a screensaver that is password protected.  Essentially, locking the system from afar.

For instance, I can run this from a terminal on the system, and it works great:
open -a /System/Library/Frameworks/ScreenSaver.framework//Versions/A/Resources/ScreenSaverEngine.app
However, if you run that from a remote SSH session, it ends up with the screen locked and unresponsive until you've killed the ScreenSaverEngine process.




Michael Wing

unread,
Oct 19, 2012, 12:15:53 PM10/19/12
to hq...@googlegroups.com
I just figured out how to do this.  I created a plist entry that calls a script every 5 seconds with launchd.  That script starts the screensaver if the file exists.  The rest of the process involves me creating that flag file with a remote SSH command.

Here's the plist:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

      <key>Label</key>

      <string>Launch_Screensaver</string>

      <key>ProgramArguments</key>

      <array>

            <string>/tmp/sswatch</string>

      </array>

      <key>StartInterval</key>

      <integer>5</integer>

</dict>

</plist>

Here's the script:

#!/bin/sh

if [ ! -e "/tmp/ssstart" ]; then exit; fi

/bin/rm -f /tmp/ssstart

set ssrunning=`/bin/ps -ax | /usr/bin/grep ScreenSaverEngine | /usr/bin/grep -v grep`

if [ "${ssrunning}" != "" ]; then exit; fi

open -F -a /System/Library/Frameworks/ScreenSaver.framework//Versions/A/Resources/ScreenSaverEngine.app




Reply all
Reply to author
Forward
0 new messages