Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Run any ScreenSaver from the Login window System
After several hours of trying, I finally got the screensaver to display from the Login Window screen (I like to lock my Mac by using the fast-user-switching login window rather than the password protected screensaver/sleep). The ScreenSaverEngine is really quite flexible. If you check out the command line switches:
 strings ScreenSaverEngine | grep "^-" 
you'll see an option called -idleCheck. All you have to do is modify your global system crontab(BACKUP FIRST!!):
sudo vi /private/etc/crontab
to execute the ScreenSaverEngine with the -idleCheck switch every 1 mins or some divisor of the total number of minutes your screensaver is set to activate _on_your_root_account (activate root, login, setup screensaver, logout, deactivate root).

Now after the activate timeout, your locked screen will display the screensaver in front of the Login Window. Pretty cool, huh? I don't think this will compromise security, but some of you others more knowledgeable of the Core Services and such will have to let me know.

[robg adds: I haven't tested this one, as my root account isn't enabled, and I have no intention of enabling it...]

    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[22,244 views]  

Run any ScreenSaver from the Login window | 19 comments | Create New Account
Click here to return to the 'Run any ScreenSaver from the Login window' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Run any ScreenSaver from the Login window
Authored by: Basilisk on Jun 15, '04 11:37:46AM

The problem with any approach that launches the ScreenSaverEngine from the commandline (or crontab, etc.) is that it doesn't initialize the ScreenSaver.framework in a manner that lets the WindowServer know that the screensaver is running.

This probably isn't a problem when we're just talking about running over the login window. Unfortunately its not clear from the hint if the recurring crontab entry suggested would also run the screensaver (as root no less) over a user login session. I suspect it won't (because the root saver won't be able to take over the console of the login session), but the hint needs to make this clear.

Any attempt to run ScreenSaverEngine directly (instead of letting the WindowServer manage it) can result in a double-launched saver which is a problem.

For more info see my comments in this prior hint:

http://www.macosxhints.com/article.php?story=2003071420174010



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: MikeTrent on Jun 15, '04 11:46:01AM

For what it's worth, the Screen Saver is managed by the Login Window, not by the Window Server. But otherwise I agree with you :-)



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: Interactive on Jun 15, '04 01:15:51PM

Yesterday, I found this:

http://clc.its.psu.edu/Labs/Mac/Resources/psuscreensaver/default.aspx



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: gshenaut on Jun 15, '04 03:32:47PM

...robg adds: I haven't tested this one, as my root account isn't enabled, and I have no intention of enabling it...

I think that "enabling" the root account in os/x-speak just means changing the password entry from "*" to an actual password. So, the root user (with uid=0) already exists (and AFAIK must always exist).

Therefore, you could do this hint without "enabling" the root account, I thimk.

Greg Shenaut



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: mazatty on Jun 16, '04 01:47:20AM

right, you don't need to "enable" the root account to do this.

all you need to do is start up System Preferences as root. to do this you can use sudo with an admin account, like so

sudo /Applications/System\ Preferences.app/Contents/MacOS/System\ Preferences

to help keep track of what apps are running as root, it's handy to change the appearance settings for root. if you use the Aqua appearance, set root's to Graphite.

[ Reply to This | # ]

Run any ScreenSaver from the Login window
Authored by: chabig on Jun 15, '04 10:37:42PM

I don't really see the point of this hint. It may be cool to run the screensaver over the login window, but it hardly seems useful. Rather than have the screensaver running, I think the smartest way to manage the machine is to have the screen go to sleep.



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: cueball on Jun 15, '04 11:40:57PM
"I don't really see the point of this hint. It may be cool to run the screensaver over the login window, but it hardly seems useful. Rather than have the screensaver running, I think the smartest way to manage the machine is to have the screen go to sleep."
That you don't see the point of the hint doesn't mean it isn't useful. Consider a educational laboratory environment - many students don't react too positively when walking into a room full of computers with blank screens, which is what you'd get if you just let the screen sleep. However, preventing the display from sleeping can lead to "loginwindowburn" [I've seen it happen on CRTs and LCDs, so it's a general problem.] I've not yet tried the hint, but it's something that I've wanted to see happen for some time at my place of work.

[ Reply to This | # ]
Edit root's crontab, not system crontab
Authored by: TrumpetPower! on Jun 16, '04 12:01:01AM

In administering a modern Unix system, you should (almost) never need to edit the system crontab.

If you want to run something at daily, weekly, or monthly intervals, use the system's periodic jobs already built for that purpose. If you want to run something at other intervals, use root's own crontab. From your favorite shell, do:

sudo crontab -e

If at all possible, of course, it's much preferable to use a non-privileged account for the task (it probably isn't possible for this particular hint). To edit your own crontab, leave out the ``sudo.'' To edit a crontab for another user:

sudo crontab -u somebody -e

By default, OS X doesn't have a root crontab, but that's okay. For help, see:

man 5 crontab

Cheers,

b&



[ Reply to This | # ]
Quick Update...
Authored by: XyberICE on Jun 16, '04 12:36:40AM
Running the ScreenSaverEngine directly is indeed troublesome as Basilisk pointed out. I found this shortly after I posted the hint so I wrote a short shell script that is run by cron instead:

#! /bin/csh

set engineRunning=`/bin/ps -auxww | /usr/bin/grep ScreenSaverEngine| /usr/bin/grep -v grep`

if("$engineRunning" == "" ) then
        exec /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -idleCheck
endif
With respect to enabling root, you do enable the "root" user once to set your Desktop & Screensaver preferences; however, you do not need to leave (nor should you) the "root" account enabled. The preferences, once written, are read on display of the ScreenSaver from the Login Window. You could also, as Greg intimates, not ever enable the "root" user and simply have the default ScreenSaver display within the default time (this just wasn't an interesting choice to me).

I had also d/l'd the Perl Scripts and App from: http://clc.its.psu.edu/Labs/Mac/Resources/psuscreensaver, but I thought this was a less invasive solution (and possibly easier to execute).

[ Reply to This | # ]

Quick Update...
Authored by: TrumpetPower! on Jun 16, '04 10:48:58AM

Golly gee, there ain't no good reason why you should have to use so much unnecessarily excessive extraneous verbiage on something like this here thingy.

ps acx | grep -q ScreenSaverEngine || /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -idleCheck

The ``c'' flag for ps restricts output to the process name only, without arguments; this prevents grep from matching itself (because just ``grep'' is shown in that line of the output). The ``q'' flag to grep is a GNUism that suppresses output. To be more portable, you'd redirect to /dev/null, but, since this'll only be run on OS X and OS X's grep is of the GNUish persuasion, we can let this one slide. The ``||'' is a conditional that only executes what follows if what preceded had a return code other than 0; grep only returns 0 if it finds something.

Cheers,

b&



[ Reply to This | # ]
Quick Update...
Authored by: Anonymous on Nov 30, '04 03:49:35PM

Just a quick addition that checks to see if anyone is logged in before checking to see if the ScreenSaverEngine is running.

/usr/bin/who | /usr/bin/awk '{ print $2 }'| grep console || ps acx | grep -q ScreenSaverEngine || /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -idleCheck



[ Reply to This | # ]
Quick Update...
Authored by: discordantus on Jan 21, '05 08:21:03PM

If we're eliminating verbiage, some happy shell globbing can tame that long pathname, too:

/System/L*/F*/Screen*/**/ScreenSaverEngine

expands to:

/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine

We could get it shorter, but I think this balances performance/error control/length pretty well.



[ Reply to This | # ]
Quick Update...
Authored by: alblue on Mar 02, '05 04:04:57AM

I'm pretty sure that the ** glob isn't a Bash-ism. You have to use single * characters.

Pity though, because ** is really handy in Ant/Maven scripts :-)



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: SunByrne on Jul 13, '04 05:58:53PM

OK, so I saved TrumpetPower's script an edited the root crontab to run that script and... it still doesn't work.

Any ideas?



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: makeitsimple on Sep 17, '05 11:09:04AM

The original hint annoyed me when I was logged-in, but would NEVER run over the login screen?!
So, I made the changes suggested in sub-replies to check for a logged-in user and now it NEVER RUNS AT ALL - at least the sub-replies did their trick properly...!
What's going on?
Someone needs to re-write this hint from scratch and get it right for everyone (anyone) in the best way (what is missing below???):
1) As your everyday/normal user, activate root account and set its password via NetInfo Mgr.
2) Make sure your login screen is set for "Name and Password" (not just "LIST OF USERS" !!!) and log out
3) Login as root
4) Open System Pref.'s and configure screen saver
5) Logout
6) Log in as your regular/normal user and DEACTIVATE root
7) Edit private/etc/crontab (vi sucks unless you use it everyday - use pico instead for sanity, but make sure to "fix" any long lines that split onto a new line), by putting the good command from the "Quick Update" sub-replies above into a script and then just running that script from crontab. I have this script in my home directory, aka ~/ScreenSave
8) Save it and watch nothing happen...oh joy!
Anyone have a clue (I sure don't)???



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: makeitsimple on Sep 17, '05 01:36:03PM

If you too have had enough of non-working cryptic hints, take reidab's edited script in his reply to the "Quick Update..." post on this hint, and use it with the the full scoop found here:
http://homepage.mac.com/gregneagle/iblog/C1833135211/E1305475742/



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: UncleJohn on Jan 22, '06 07:38:34AM
I found the check for logged in users to be unreliable under 10.4.4 with FUS enabled. But using the "open" command on the ScreenSaver app itself seems to solve a lot of problems.

1. If a user is logged in, it will show that user's screen saver

2. If login window is displayed, shows the default screen saver

I can skip the logged-in user step entirely, and the framework just seems to do the right thing. I haven't figured out how to pass command-line args via the "open" command, so the idle check is done separately. I also left in the check for screen saver already running, but this does not even seem necessary.

To change the default screen saver, edit /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/EngineDefaults.plist, changing moduleName to whichever one you want to use. The default is "Flurry" - I used "Pictures Folder".

If you use "Pictures Folder", you must give one to the root user. I made a symlink "Pictures" in /var/root to the folder I wanted to use. There is no need to enable root user login.

For some reason, I could never get this to work using launchd (black screen). But it works fine under cron.

I'm also not sure why it uses the default screen saver, even if root user is enabled has one specified in preferences. YMMV.


#!/bin/sh
# First check to see if the screen saver is already running!
procList=`/bin/ps -auxwww | /usr/bin/grep -c "ScreenSaverEngine"`

if [ $procList -lt 2 ]; then
  # the screen saver is not already running, let's launch it,
  # but only if the system has been idle at least 5 minutes
  #get the system idle time in seconds
  idleTime=`/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/perl -ane 'if (/Idle/) {$idle=int((pop @F)/1000000000); print $idle,"\n"; last}'`
  if [ $idleTime -gt 300 ]; then
    open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
  fi
fi


[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: makeitsimple on Feb 14, '06 04:09:23PM

OK, as Uncle John states, this fails with only a black screen using launchd with Tiger - anyone have any ideas?

Thanks!



[ Reply to This | # ]
Run any ScreenSaver from the Login window
Authored by: christym on Dec 05, '06 10:27:36AM

I've sucessfully done this mod on countless PPC-based Macs, however I cannot get it to run at all on an Intel-based Mac. It just defaults to a black screen. Is this because the screensavers are still written in the PPC-based binary, and they have to be run with Rosetta?



[ Reply to This | # ]