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


Click here to return to the 'Quick Update...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
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 | # ]