#!/bin/bash #----------------------------------------------------------- # re_store_present v2 # by jwm-art.net # # scrolls two messages posted on netbehaviour discussing # the usage of code in an artistic context... # # this script is for Linux systems running BASH # (run this script in a terminal...) # #----------------------------------------------------------- # clear the terminal display clear width=80 if [ "x$1" == "x-width" ]; then # see http://linux.derkeiler.com/Mailing-Lists/SuSE/2008-05/msg00265.html if [ $2 -eq $2 2> /dev/null ]; then width=$2 fi fi # below are the message in a secret coded form. # the tr command was used on the original message # and the output cut+pasted into this script. secret_msg1=".......... I xjti puifs qfpqmf xpvme qvu vq uijoht mjlf uijt - I'n gbtdjobufe cy ipx nvdi jt sfwfbmfe uispvhi qspnqu rvpuft, tpguxbsf evnqt, bmm uif efcsjt bspvoe xibu xf dsfbuf. Iu't sfbmmy ufbtjoh uif ivnbo/nbdijof joufsgbdf joup b upubmmy ejggfsfou ejsfdujpo. A cppl pg uiftf uijoht xpvme cf xpoefsgvm........... Aoe gps uiptf xip dpvmeo'u sfbe uif dpnnboet? Ewfo jg ypv dbo, jg gps fybnqmf ypv tby l:> obop {y} - xip xpvme sfbmmy lopx xibu't _jo_ y? Bvu b siyuin jt ftubcmjtife - uibu't usvf jo cpui pvs dbtft I uijol, boe qspcbcmy xjui boypof fmtf xip xpslt uijt xby........... I sfbe ny fnbjm jo qjof (4.64) boe Gnbjm xifo I ibwf up - boe xbt uijoljoh uif puifs eby - qjof tffnt jotuboubofpvt uibolt up qbojy.dpn - hnbjm I'n bmxbyt xbjujoh, ju tuvuufst, ofwfs gffmt nvdi mjlf b dpowfstbujpo, bmuipvhi dibu't ejggfsfou pg dpvstf........... - Ambo.........." secret_msg2="..........My dvssfou bshvnfou dpodfsojoh uif ejtqmby pg dpef (bt pqqptfe up pomy uif qspdftt/pvudpnf) jt uibu uif gbdu uibu uif dpef dpoubjot jogpsnbujpo uibu jt ejsfdumy sfmbujwf up b dpodfquvbm sfbejoh pg uif xpsl, jt joftdbqbcmf. Tif qspcmfn, po uif puifs iboe, jt uibu qfpqmf xip epo'u sfbe dpef, tffn up ibwf b hfofsbm bwfstjpo up cfjoh qvu jo uibu qptjujpo (xifsf uify nvtu bdlopxmfehf uif dpef). Tijt jt tpnfuijoh xf offe up ifmq qpufoujbm bvejfodft up pwfsdpnf. Ppjoujoh pvu mjuumf uijoht ifsf boe uifsf xjmm ifmq up tipx uibu ju't opu bt dpnqmjdbufe bt nptu opo-dpefst uijol. Wsjujoh dpef dbo cf b dpnqmjdbufe qspdftt cfdbvtf ju ibt up xpsl cvu sfbejoh dpef jt bmuphfuifs ejggfsfou boe ypv epo'u offe up lopx ipx up xsjuf dpef up cf bcmf up sfbe dpef. Np npsf uibo ypv offe up cf bcmf up xsjuf b cppl up sfbe b cppl ps qbjou b qbjoujoh up sfbe b qbjoujoh. Tijt xibu xf offe up nblf lopxo...........cftu s, Pbmm.........." src_line_count=`cat $0 | wc -l` src_first_line=-10; src_line=0 # decode messages. (by enclosing a command in backticks # it allows to capture the output of that command(s) into # a variable, in this case, called msg1 & msg2). # also, add a few more extraneous characters to messages # to give people a chance to read the beginning of them # without waiting for them to scroll back round... msg1=`echo "- - - - - - - -" $secret_msg1 | tr b-z a-x` msg2=`echo "- - - - - - - -" $secret_msg2 | tr b-z a-x` msg3=`echo "- - - - - - - -" $this_file` # note: the original (encoded) messages have line breaks # within them, these are removed by echo-ing them without # enclosing quotes, while within the scroll-loop (below) # the messages are echo-ed within enclosing quotes (which # preserves any spaces at beginning of output... # length in characters of messages: # commented out due to use of function rotate_msg len1=${#msg1}; len2=${#msg2}; len3=${#msg3}; # reset cursor contains an escape-sequence which # resets the cursor position to the top-left of # the terminal reset_cursor="\033[0;0H"; erase_line="\033[0K"; ticker=0; while true do echo -e $reset_cursor # -e enables processing of escape sequences. echo "${msg1:0:width}" # most terminals are usually 80 chars wide. first=${msg1:0:1} # first character in msg. rest=${msg1:1:len1-1} # remainder of msg. msg1=${rest}${first} # reconstitute msg (so first is now last). echo -e "\n" # drop down a few lines echo "${msg2:0:width}" # now do the same for second message... first=${msg2:0:2} # (but now scrolling two chars each time) rest=${msg2:2:len2-2} msg2=${rest}${first} echo -e "\n" src_display_count=15 src_line=src_first_line; while [ "$src_display_count" -gt "0" ] do let src_line=src_line+1 if [ "$src_line" -lt "1" ]; then echo elif [ "$src_line" -lt "$src_line_count" ]; then # need more control of output than using # head alone provides, so capture it's output # and output it using echo ln=`head -n $src_line $0 | tail -n 1` echo -n "${ln:0:width}" # -n don't output newline echo -e $erase_line # to erase remainder of line # this method avoids flickering due to erase+redraw. else echo fi let src_display_count=src_display_count-1; done let ticker=ticker+1 if [ "$ticker" -eq "2" ] then ticker=0 let src_first_line=src_first_line+1 if [ "$src_first_line" -eq "$src_line_count" ] then src_first_line=-10 fi fi sleep 0.1 # a pause to prevent scrolling too fast. done #end of file