home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / sun / volume1 / rntool / rn.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1989-07-20  |  2.0 KB  |  90 lines

  1. #!/bin/csh -f
  2. #
  3. #    rn.sh - News reading program - check for news every so often,
  4. #        change icon etc. when news is present/absent.
  5. #
  6. #    Normally invoked by "tooltool -f rn.tt".
  7. #
  8. #    Written by Jonathan Bowen, July/August 1988
  9. #    Based on "newsreader", written by Jonathan Bowen, October 1987
  10. #    Based on a "newsread" shell script by Jeremy Jacob, 9 Oct 87
  11. #    Updated by Jonathan Bowen, February 1989
  12. #
  13.  
  14. onintr -
  15.  
  16. if (! ${?ROOT}) then
  17.   set ROOT=/usr/news
  18. endif
  19.  
  20. set PATH=/bin:/usr/bin:/ucb/bin:/usr/local/bin:$ROOT/bin
  21.  
  22. if (! ${?PROGNAME}) then
  23.   set PROGNAME=`basename $0`
  24. endif
  25.  
  26. # Directory containing icons for this shell script
  27. set ICONDIR=$ROOT/images
  28.  
  29. # Interval in seconds between checks for news
  30. set INTERVAL=600
  31.  
  32. # BEL is the ASCII bell character (octal 007)
  33. set BEL=`echo -n x | tr x '\007'`
  34. # ESC is the ASCII escape character (octal 033)
  35. set ESC=`echo -n x | tr x '\033'`
  36.  
  37. # "rn" is the default newsreading program unless NEWSPROG is set
  38. if (! ${?NEWSPROG}) then
  39.   set NEWSPROG=rn
  40. endif
  41.  
  42. echo -n "${ESC}]L${ESC}\"
  43.  
  44. while (1)
  45.  
  46.   echo -n "${ESC}[2t"
  47.   set NEWNEWS=`rn -c`
  48.  
  49.   if (! $#NEWNEWS) then
  50.     echo -n "${ESC}]I$ICONDIR/nonews.icon${ESC}\"
  51.     echo -n "${ESC}]l$PROGNAME - No news${ESC}\"
  52.  
  53. # Check for new news
  54.     while (! $#NEWNEWS)
  55.       onintr read
  56.       sleep $INTERVAL
  57.       set NEWNEWS=`rn -c`
  58.       goto cont
  59. # Read news anyway
  60. read:
  61.       onintr -
  62.       echo -n "${ESC}]l$PROGNAME - Reading news${ESC}\${ESC}[1t"
  63.       clear
  64.       $NEWSPROG
  65.       clear
  66.       echo -n "${ESC}[2t${ESC}]l$PROGNAME - No news${ESC}\"
  67. cont:
  68.       onintr -
  69.     end
  70.  
  71. # Enable "News" icon.
  72.     echo -n "${ESC}]I$ICONDIR/news.icon${ESC}\"
  73. # Sound bell  ("Read   all    a------bout   it!")
  74.     sunbell     200 50 200 50 100 50 400 50 100
  75. # Sound bell twice (use if "sunbell" is not available)
  76. #   echo -n "${BEL}" ; sleep 1; echo -n "${BEL}"
  77. # Sound bell and make icon visible  (Not safe if screen is locked)
  78. #   echo -n "${BEL}${ESC}[5t" ; echo -n "${BEL}"
  79.   endif
  80.  
  81. # Read new news
  82.   echo -n "${ESC}]I$ICONDIR/news.icon${ESC}\"
  83.   echo -n "${ESC}]l$PROGNAME - News${ESC}\"
  84.   clear
  85.   $NEWSPROG
  86.   clear
  87.  
  88. end
  89.  
  90.