[comp.sources.misc] v05i089: Inspiratiional Shell utility "aff"

smd@lcuxlm.ATT.COM (Dahmen Steve) (12/23/88)

Posting-number: Volume 5, Issue 89
Submitted-by: "Dahmen Steve" <smd@lcuxlm.ATT.COM>
Archive-name: aff

[Our dear comp.sources.unix moderator thought this one was interesting.

This thing only works on VT100 compatibles -- and if you run BSD UNIX, you
will need to hack the "echo" commands.  (Query:  why didn't the author use
tput, since the script looks System-V-ish to me?)  ++bsa]

The following is a little shell i wrote out that i find very useful.
Basically, it will put a message in the center of your sceen every
half an hour (default, and changeable).  Its original purpose was to
work with a self-help technique known as 'affirmations'.
Psychologists have shown that the repetition of a powerful message
into the conscious mind can affect the sub and un-conscious portions
also.  By using such phrases as "I have a completely healthy body",
you can begin to help increase the level of health in your body;
simple mind over matter.  Its best to keep them short and sweet, and
to avoid using negatives like not, never, no, etc because its been
found that the subconscious literally "edits out" negatives (since
thats the function of the logical part of the brain).

The other use is just to remind yourself of anything: a prayer, a
hopeful thought, something that lightens you up during the day.  I
find this program does wonders to keep up my energy during a
stress-ful workday.

Just put all the lines below the "==============...." into a file, aff, in
your /bin directory.  [Now this is a shar, like everything else.  ++bsa]
Edit aff to change any of the defaults (especially if you want your message
to appear more or less than the default 30 minutes.  Edit your .profile to
include the line:

aff N

and you will be promted every login for a new message (affirmation).
To use the previous day's message, just hit return.  If you already
have aff running in the background or wish not to have the message
appear, type 'q'.  If at any time (like the department head has a
meeting with you in your office) you can type 'aff' at the terminal
and the message wont be displayed until you reactivate.

NOTE: Since i havent had time to rewrite it in C, the only terminals I
know it works on is the ATT 5425, 4425, and vt100s.  it may work on
others.  ALSO: you may need a tad of patience if you use vi a lot; you
will need your refresh screen command (^L in vi) so you can see what
aff "erased".  But the personal benefits gained made it worthwhile for
me.
=====================================================================
#! /bin/sh
# This file was wrapped with "dummyshar".  "sh" this file to extract.
# Contents:  aff
echo extracting 'aff'
if test -f 'aff' -a -z "$1"; then echo Not overwriting 'aff'; else
sed 's/^X//' << \EOF > 'aff'
X#program 'aff' to regularly display messages to your terminal.
X#1st arg is 1=ON, 0=OFF , N=New Affirmation, C=Change Affirmation
X#2nd is optional sleep time (minutes)
X#3rd is optional new affirmation
X
Xstime=1800 		#  default; every half hour
Xafflist=$HOME.afflist	# This is a compiled list of all your messages
Xaffile=$HOME/.aff	# The file used to keep track of the current aff.
X			# From login to login.
Xexport stime afflist affile
X
Xif [ $# -gt 1 ]  # if there is a 2nnd arg
Xthen
X   stime=`expr $2 \* 60`
X   if [ $# -gt 2 ] #if there is a 3rd arg, 2nd is 1
X   then
X	shift; shift
X        echo $@ > ~/.aff
X   fi
Xelse
X   if [ $# = 0 ]
X   then
X      rm $affile
X      echo Affirmations turned off.
X      exit
X   else
X      case $1 in
X	 2) : ;;
X         1|c) echo 'Change Affirmation to: \c'
X	      read AFF
X	      case $AFF in
X  		'') ;;
X  		q|Q) exit;;
X  	  	*) echo $AFF >> $afflist
X    	    	echo $AFF > $affile
X		;;
X      	      esac ;;
X         N) echo 'Enter: New affirmation: \c'
X	      read AFF
X	      case $AFF in
X  		'') ;;
X  		q|Q) exit;;
X  	  	*) echo $AFF >> $afflist
X    	    	echo $AFF > $affile
X		;;
X      	      esac ;;
X         off|0) rm $affile; exit;;
X         *) echo I dont know this option!; exit;;
X      esac
X(
Xwhile test -r $affile
Xdo
XAFF=`cat $affile`
Xecho "\0337\c"
Xcscreen=\033\[2J
Xretn=\033\[0m
Xtemp=`wc -c $affile | cut -c1-7`
Xti=`expr 72 - $temp`
Xtti=`expr $ti / 2`
Xpos=\033\[5m\033\[13\;${tti}f
Xecho "$cscreen$pos$AFF$retn\0338\c"
Xsleep $stime
Xdone
X) > /dev/tty &
X   fi
Xfi
Xecho starting affirmations every `expr $stime / 60` minutes.
Xexit 0
EOF
chars=`wc -c < 'aff'`
if test $chars !=    1637; then echo 'aff' is $chars characters, should be    1637 characters!; fi
fi
exit 0
===================================================================
Steve Dahmen                                 att.ATT.COM!lcuxlm!smd
"Love The Planet, Love Yourself!"                  201-580-5687 (W)
* :-) * :-) * :-) * :-( * :-( * :-( * :-( * :-( * :-( * :-( * :-( *