home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume22 / aff / part01 next >
Text File  |  1991-08-17  |  6KB  |  181 lines

  1. Newsgroups: comp.sources.misc
  2. From: Steve Dahmen  <smd@vab01.larc.nasa.gov>
  3. Subject:  v22i025:  aff - Inspirational Shell utility, Part01/01
  4. Message-ID: <1991Aug17.182102.7266@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 5e519aaa07e02791df21d3dc43bfcef6
  6. Date: Sat, 17 Aug 1991 18:21:02 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Steve Dahmen  <smd@vab01.larc.nasa.gov>
  10. Posting-number: Volume 22, Issue 25
  11. Archive-name: aff/part01
  12. Environment: tput, getopt
  13. Supersedes: aff: Volume 5, Issue 89
  14.  
  15. The following is a little shell I wrote out that I find very useful.
  16. Basically, it will put a message in the center of your sceen every
  17. half an hour (default, and changeable).  Its original purpose was to
  18. work with a self-help technique known as 'affirmations'.
  19. Psychologists have shown that the repetition of a powerful message
  20. into the conscious mind can affect the sub and un-conscious portions
  21. also.  By using such phrases as "I have a completely healthy body",
  22. you can begin to help increase the level of health in your body;
  23. simple mind over matter.  Its best to keep them short and sweet, and
  24. to avoid using negatives like not, never, no, etc because its been
  25. found that the subconscious literally "edits out" negatives (since
  26. thats the function of the logical part of the brain).
  27.  
  28. The other use is just to remind yourself of anything: a prayer, a
  29. hopeful thought, something that lightens you up during the day.  I
  30. find this program does wonders to keep up my energy during a
  31. stress-ful workday.
  32.  
  33. Unshar this file and put aff, in your /bin directory.  Edit aff to 
  34. change any of the defaults (especially if you want your message to
  35. appear more or less than the default 30 minutes.  Edit your .profile 
  36. to include the line:
  37.  
  38. aff N
  39.  
  40. and you will be promted every login for a new message (affirmation).
  41. To use the previous day's message, just hit return.  If you already
  42. have aff running in the background or wish not to have the message
  43. appear, type 'q'.  If at any time (like the department head has a
  44. meeting with you in your office) you can type 'aff' at the terminal
  45. and the message wont be displayed until you reactivate.
  46.  
  47.  -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  48. Steve Dahmen, Systems Analyst                         (804) 864-4519 (W)
  49. Vigyan Research, Inc .- NASA Langley Research Center                    
  50. Internet: smd@vab01.larc.nasa.gov
  51. =====================================================================
  52. #! /bin/sh
  53. # This is a shell archive.  Remove anything before this line, then feed it
  54. # into a shell via "sh file" or similar.  To overwrite existing files,
  55. # type "sh file -c".
  56. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  57. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  58. # Contents:  aff
  59. # Wrapped by kent@sparky on Sat Aug 17 13:14:32 1991
  60. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  61. echo If this archive is complete, you will see the following message:
  62. echo '          "shar: End of archive."'
  63. if test -f 'aff' -a "${1}" != "-c" ; then 
  64.   echo shar: Will not clobber existing file \"'aff'\"
  65. else
  66.   echo shar: Extracting \"'aff'\" \(2591 characters\)
  67.   sed "s/^X//" >'aff' <<'END_OF_FILE'
  68. X#!/bin/sh
  69. X# program 'aff' to regularly display messages to your terminal.
  70. X# aff v 2.0 features:
  71. X#    Uses tput, so now it should run on any terminal terminfo knows about.
  72. X#    Now aff remembers your previous invocation's affirmation
  73. X#    No args means turn it off if its on, turn it on if its off!
  74. X#    Clears screen when you turn it off for those emergencies :-),
  75. X#        -q disables the autoclear
  76. X#    Now uses getopts and regular unix flag format.
  77. X#    Much more intuitive use.
  78. X#    Removed .afflist; just another . file to keep track of.
  79. X
  80. X# -n <new affirmation> to start it with a new affirmation
  81. X# -c <new affirmation> to change affirmations while running
  82. X# -t <sleeptime>       change # mins between displays from default 30
  83. X# -r                   in the rare case aff says its running and it isn't.
  84. X
  85. Xstime=4  #1800         #  default; every half hour
  86. Xonaffile=$HOME/.affon    # The files used to keep track of the current aff.
  87. Xoffaffile=$HOME/.affoff            # From login to login.
  88. XUSAGE="Usage: aff -q | {[-t <sleeptime>] [-n <affirmation> | -c <affirmation> ]}"
  89. Xexport stime onaffile offaffile
  90. Xtrap "mv $onaffile $offaffile" 2 3 1
  91. X
  92. Xturnoff() {
  93. X   mv $onaffile $offaffile
  94. X}
  95. X
  96. Xwhile getopts qrt:n:c: C
  97. Xdo
  98. X   case $C in
  99. X     t) stime=`expr $OPTARG \* 60` ;;
  100. X     n) if test -r $onaffile
  101. X    then
  102. X           echo "Aff is already running; use -c option." >&2
  103. X       exit 1
  104. X    fi
  105. X    echo "$OPTARG \c" > $offaffile 
  106. X    ;;
  107. X     c) if test ! -r $onaffile
  108. X    then
  109. X       echo "Sorry, -c option only good while aff is running." >&2
  110. X       exit 1
  111. X    fi
  112. X    shift `expr $OPTIND - 1`
  113. X    OPTARG="$OPTARG $*"
  114. X    echo "$OPTARG" > $onaffile 
  115. X    exit 0
  116. X    ;;
  117. X     r) mv $onaffile $offaffile  ;;
  118. X     q) turnoff; exit 0;;
  119. X    \?) echo "\n\n$USAGE\n\n" >&2; exit 1 ;;
  120. X   esac
  121. Xdone
  122. Xshift `expr $OPTIND - 1`
  123. X
  124. Xif test -r $onaffile
  125. Xthen
  126. X   turnoff
  127. X   tput clear
  128. X   exit 0
  129. Xelse
  130. X   if test -r $offaffile
  131. X   then
  132. X      echo "$*" >> $offaffile  # in case they didn't use quotes
  133. X      mv $offaffile $onaffile
  134. X   else
  135. X      echo "Affirmation: \c"
  136. X      read $AFF
  137. X      echo "$AFF" > $onaffile
  138. X   fi
  139. Xfi
  140. X
  141. XLASTROW="`tput lines`"
  142. XLASTCOL="`tput cols`"
  143. XAFFROW=`expr $LASTROW / 2`
  144. XBOLDIT="`tput smso`"
  145. XNOBOLD="`tput rmso`"
  146. XCINV="`tput civis`"
  147. XCSAV="`tput sc`"
  148. XCRET="`tput rc`"
  149. XLEAVE="$CSAV$CINV$BOLDIT"
  150. XRETURN="$NOBOLD$CRET$CVIS"
  151. XAFF=`cat $onaffile`
  152. Xtemp=`cat $onaffile | wc -c `
  153. Xti=`expr 72 - $temp`
  154. Xtti=`expr $ti / 2`
  155. XPOS=`tput cup $AFFROW $tti`
  156. Xexport LEAVE RETURN AFFROW POS
  157. X(
  158. Xwhile test -r $onaffile
  159. Xdo
  160. XAFF=`cat $onaffile`
  161. Xecho "${LEAVE}$POS$AFF$RETURN\c"
  162. Xsleep $stime
  163. Xdone
  164. X)  > /dev/tty &
  165. Xecho "starting affirmations every `expr $stime / 60` minute(s)."
  166. Xexit 0
  167. END_OF_FILE
  168.   if test 2591 -ne `wc -c <'aff'`; then
  169.     echo shar: \"'aff'\" unpacked with wrong size!
  170.   fi
  171.   # end of 'aff'
  172. fi
  173. echo shar: End of archive.
  174. exit 0
  175. exit 0 # Just in case...
  176. -- 
  177. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  178. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  179. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  180. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  181.