#!/bin/sh # # xxlock -- runs xlock with random savers that YOU LIKE! # For Solaris xlock (openwindows) of 23 March 1992 # by Patrick J. Naughton and Sun. # From an original script, xxlock, by Leo Breebaart # (using nawk rand function to provide a value between 0 and 1) # Adapted to suit SunOS-supplied xlock by Lloyd Wood . # (using /usr/local/bin/random with -er parameters on Leo's advice) # Later modified to suit Solaris environment by Lloyd. # (using broken random and ancient awk; should be more cross-platform) # Lloyd basically eventually followed Leo's Good Advice, after # lots of pointless messing around. # Such as learning awk a year after Leo provided him with an awk script # including a random number generator. An awk script that was really # a nawk script, in fact; since the random function isn't in the original awk, # Lloyd, now enlightened, is not surprised that he could never get it to work. # to be crossplatform, screen colours are now set in a wrapper, lock. # ADVERTISING PLUG! # everything you never wanted to know about screensavers, at: # # !! Change these to reflect your paths !! # Where is the xlock program kept? # ('real' unix setups - not Sun - probably keep it in /usr/bin/X11) scrlock=/usr/openwin/bin/xlock # Where is the random number generator kept? # 'man random' should say where, if the right man page is installed. # (i.e. you don't want to read all about the cc or fortran functions) # properly configured unix setups should have it in /usr/local/bin # or it could be in /usr/games or /usr/local/games rnd=/usr/local/bin/random # the above wouldn't be necessary if people learned to set their paths # correctly, anyway. # xlock options we want to generate values for, and their defaults # Set the saturation. # (This is inelegant, but it works.) # set a default just in case the code below fails. sat="0.5" range=11 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range whichmode=$? # later versions of awk or nawk will demand -v r=$range # under SunOS, the following did the same as the lines above: # $rnd -er 11 # whichmode=$? # but random under Solaris here ignores -er, with the result that whichmode # was set to the length of the random number generated+return. Since most # numbers generated were five digits long, whichmode always got to be 6. # Not very random. case $whichmode in 1) sat="0.1";; 2) sat="0.2";; 3) sat="0.3";; 4) sat="0.4";; 5) sat="0.5";; 6) sat="0.6";; 7) sat="0.7";; 8) sat="0.8";; 9) sat="0.9";; 10) sat="1.0";; 11) sat="0";; *) sat="1.0";; # default to full colour if things go wrong - they'll never even notice. esac # selecting mode random as default is a good way of making this # script look like it's more-or-less working, even when it isn't. # comment out the line below when debugging mode="random" # default parameter must be a positive integer - set just in case. num=30 # Generate a number between 0 and (last saver you want to see). # For all the savers below, make the digit in the next line 9. range=6 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range whichmode=$? # Here, whichmode is specifically customised for the limited Sun version # of xlock, which has only eight different savers. # Savers below detailed in Sun man pages. SunOS 5.4, 23 March 1992 case $whichmode in 1) mode="swarm" range=500 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 2) mode="rotor" range=1000 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 3) mode="qix" range=35 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 4) mode="hop" range=10000 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 5) mode="flame" range=35 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 6) mode="pyro" range=35 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 7) mode="image" range=100 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 8) mode="life" range=20 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; 9) mode="blank";; *) range=25 $rnd | awk '{ s = $0+0 } {s = s - int(s/r)*r +1} {exit s}' r=$range num=$?;; esac # if you make the random number generated bigger than the number of # modes, we are defaulting to random, so it looks like we're still working. # And we set a random (if low) parameter, which is still better than # -mode random by itself. # Boring Sun-logo blankers are placed at the end so we can remove them by # just decreasing the initial value passed to rnd (nominally 8 for all) # Only the blank option is less popular, and pointless unless we # add -enablesaver as an option. # When debugging, use the first line below as a check on what appears, # otherwise just comment it out. # echo $scrlock -mode $mode -batchcount $num -sat $sat -remote $* exec $scrlock -mode $mode -batchcount $num -sat $sat -remote $* # see how -remote is added to 'sleep' X terminals, too. We're wastrels! exit 0 # Notice how the initial switches provided to xxlock are added at the end of # the xlock command. This allows the user to override xxlock-generated # options (assuming left-to-right parsing), so that: # 'xxlock -mode random' selects from all savers with a random (weighted # low) value for -batchcount, i.e. we're still doing better than what # 'xlock -mode random' does. # 'xxlock -mode blank' and 'xxlock -mono' do what you would intuitively # expect. # This allows xxlock to be a full, more interesting, replacement for xlock # as far as the user is concerned. # Original Copyright (C) Leo Breebaart, 1995. # Modifications Copyright (C) Lloyd Wood, 1995, 1996. # As if anyone cares. Especially Sun, without whom this wouldn't have been # necessary in the first place.