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


Click here to return to the 'timkered script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
timkered script
Authored by: lithosyork on Sep 29, '02 01:22:35PM
i tinkered with foons script and then i started again! heres a new version - comments welcome, bug fixes etc theres usage info and a few comments, works pretty much the same, you can choose a few more options.

i keep my stuff in /usr/local/bin . call it what you like.

cheers...

--cut here--
#!/bin/sh
#  above line specifies which shell to useto execute this file
#  author: rob stone.  psychology, university of york, uk. modified by
#  idea from foon (Joel Kraut) on  mscosxhints see
#  http://www.macosxhints.com/article.php?story=20020830050630964

#set -x
#debugging switch - uncomment to see what is happening

#shell variables set in one place for ease
PATH=/bin:/sbin:/usr/bin:/usr/sbin  # set to make sure nothing odd gets run
SAVER="/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine "
USER=`users`

NICE="nice -n 20 "        # run at a lower priority so as to free up resources
BKG=0                     # set to 1 if you always wnat this and you can alter the behaviour of -b
SWITCHES=" -background "  # set to run in the background,

function usage () {
# show the usage info with the options
    PROGNAME=`basename $0` ;
    echo "Usage: $0  [-d|-h|-k|-l]  [-b] [-f] [-r|-m modname]"
    echo "  $PROGNAME       use currently chosen module"
    echo "  $PROGNAME -b    background the task (&) and return control to terminal"
    echo "  $PROGNAME -d    display all the running screensaver modules and exit"
    echo "  $PROGNAME -f    display in the foreground - funky"
    echo "  $PROGNAME -h    show this help screen and exit"
    echo "  $PROGNAME -k    kill all the running screensavers and exit"
    echo "  $PROGNAME -l    list available modules for $USER and system and exit"
    echo "  $PROGNAME -m modname use module Modname"
    echo "  $PROGNAME -r    use the Random module"
    echo
    echo "Note: specifing more than one -r or -m will use the last one listed"
    echo
    exit 0 
}   


function killsavers() {
# get the ps lines for very occurence  the pid is the first 5 chars
    for ID in `ps -c | fgrep "ScreenSaverEn" | cut  -c1-5  `
    do
        kill $ID
    done
}  

# loop around the flags processong each one.
while [ $# != 0 ]
do
    case $1 in 
            -b) BKG=1
                shift
                ;;
            -d) ps -c  | fgrep "ScreenSaver"
                exit 0 
                ;;

            -f) SWITCHES=" -foreground " 
                shift
                ;;
            -l) echo "==== USER $USER  [ /Users/$USER/Library/Screen Savers] ======"
                ls  /Users/$USER/Library/Screen Savers/ | fgrep .saver
                echo "==== SYSTEM [/Library/Screen Savers/] ======"
                ls  /Library/Screen Savers/ | fgrep .saver
                exit 0
                ;;
            -k) killsavers
                exit 0 
                ;;
            -r) SWITCHES="$SWITCHES -module Random" 
                shift
                ;;
            -m) SWITCHES="$SWITCHES -module $2" 
                shift
                shift
                ;;  
                
            *)  usage  
                ;;
        esac
        
done

killsavers

case $BKG in
    1)  $NICE $SAVER $SWITCHES & ;;
    *)  exec $NICE $SAVER $SWITCHES  ;;
esac

-- cut here --
apologies for the double line spacing - dont know whats happening there !

[ Reply to This | # ]
cpu monitor as desktop
Authored by: tex210 on Sep 30, '02 05:32:25AM

i'm not a programmer, but i was wondering if screensavers were a type of app? the reason i'm wondering is that i want to run cpu monitor (or equivilent) as my desktop. I know it sounds useless, but i love leaving it running (expanded view) large to see my computer "think"(silly I know) but it floats above my desktop icons... is there a way to make a screensaver get the information on cpu usage and display an active graph? i'm thinking a screensaver to desktop method would be the only way to get this to work... Am i way off and just dreaming?



[ Reply to This | # ]
timkered script
Authored by: TigerPRO on Jun 22, '05 09:49:12AM

Just an update for using this script with Tiger. But it also enhances it's use under Panther. Adding following extra lines includes support for .slideSaver and .qtz (quart composer things) screen savers. Also by adding the "/System/Library/Screen Savers" directory, you will then be able to call each of the pre-installed screen saver modules as well.

Replace this line of code in the original script:

[code]
ls /Users/$user/Library/Screen\ Savers/ | grep .saver
ls /System/Library/Screen\ Savers/ | grep .saver
ls /Library/Screen\ Savers/ | grep .saver
[/code]

[b]With this one:[/b]

[code]
ls /Users/$user/Library/Screen\ Savers/ | grep .saver
ls /System/Library/Screen\ Savers/ | grep .saver
ls /System/Library/Screen\ Savers/ | grep .slideSaver
ls /System/Library/Screen\ Savers/ | grep .qtz
ls /Library/Screen\ Savers/ | grep .saver
[/code]



[ Reply to This | # ]