home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1986 < prev    next >
Internet Message Format  |  1990-12-28  |  3KB

  1. From: davidsen@sixhub.UUCP (Wm E. Davidsen Jr)
  2. Newsgroups: alt.sources
  3. Subject: Xenix screenblanker - updated, with docs
  4. Message-ID: <2151@sixhub.UUCP>
  5. Date: 23 Oct 90 23:45:50 GMT
  6.  
  7.  
  8.   The first post was pretty ugly, here's one with a man page and
  9. slightly better command interface. This blanks console screens on Xenix
  10. after a period of inactivity.
  11.  
  12. #!/bin/sh
  13. # shar:    Shell Archiver  (v1.27)
  14. #
  15. #    Run the following text with /bin/sh to create:
  16. #      scrnblank.1
  17. #      scrnblank
  18. #
  19. sed 's/^X//' << 'SHAR_EOF' > scrnblank.1 &&
  20. X.TH scrnblank L local
  21. X.SH NAME
  22. Xscrnblank \- blank console after a period of inactivity
  23. X.SH SYNOPSIS
  24. Xscrnblank [ idle_mins [ inverval_sec ] ]
  25. X.SH DESCRIPTION
  26. XChecks periodically to see if all virtual consoles have been inactive
  27. Xfor a length of time. If so the screen is blanked.
  28. X
  29. XIn your system rc file for user daemons (/etc/rc.d/7 directory) you can
  30. Xadd the command "scrnblank &".
  31. X.SH EXAMPLES
  32. X  scrnblank
  33. X  scrnblank 20
  34. X  scrnblank 1 20
  35. X.SH LIMITATIONS
  36. XThis program requires a virtual console dedicated as a blank screen.
  37. XThis is not usually a problem.
  38. X.SH FILES
  39. X/etc/rc.d/7/
  40. X.SH AUTHOR
  41. XBill Davidsen, davidsen@crdos1.crd.ge.com
  42. X.SH Copyright
  43. XCopyright 1990 by Bill Davidsen, all rights reserved. May be freely used
  44. Xand distributed.
  45. SHAR_EOF
  46. chmod 0644 scrnblank.1 || echo "restore of scrnblank.1 fails"
  47. sed 's/^X//' << 'SHAR_EOF' > scrnblank &&
  48. X#!/bin/sh
  49. X
  50. X# blank screen for Xenix @(#)scrnblank - v1.3, 10/23/90 19:22:10
  51. X
  52. X# ================ customize begins
  53. X# this is the screen number for the blank screen
  54. X#    it should not be in use, preferably without a getty,
  55. X#    since the cursor is not restored. ie. tty07 would be 7
  56. XBLANK_SCR=7
  57. X#=============== end of customize features
  58. X
  59. X# calling sequence:
  60. X#    scrnblank [mins [interval]]
  61. X#  Checks every {interval} seconds (default 60) to see if all console
  62. X#  screens have been idle for {mins} minutes (default 5), and switches to
  63. X#  the virtual screen selected below and blanks it.
  64. X
  65. X# This is the time to wait in minutes. 
  66. X#    It may be set from the command line, too
  67. Xif [ $# -ge 1 ]
  68. Xthen    WAIT=$1
  69. Xelse    WAIT=5
  70. Xfi    #
  71. X
  72. X# this is the interval at which to test
  73. Xif [ $# -ge 2 ]
  74. Xthen    LOOPSEC=$2
  75. Xelse    LOOPSEC=60
  76. Xfi    #
  77. X
  78. X# Logic:
  79. X#    the output of "who -u" is scanned to see if all console
  80. X#    logins are over N minutes unused. Then the screen is blanked
  81. X#    by setting cursor off and doing a clear screen.
  82. X#    This program must be run from a tty
  83. X
  84. Xwhile true; do
  85. X  who -u |
  86. X  awk '
  87. X  $2 ~ /tty[01][0-9]/ {
  88. X    # Get the time field
  89. X    time=substr($0, 38, 5)
  90. X    if (time == "old") continue
  91. X    split(time, xtime, ":")
  92. X    idle = 60*xtime[1] + xtime[2]
  93. X    if (WaitStart < idle) continue
  94. X    Active = 1
  95. X  }
  96. X
  97. X  END {
  98. X    # really ugly way to change screens
  99. X    if (!Active) {
  100. X      # form the device name
  101. X      OutDev=sprintf("/dev/tty%02d", BlankScrn)
  102. X      # switch to the screen for blank use
  103. X      printf("\r\033[%02dz", BlankScrn-1) > OutDev
  104. X      # cursor off, CLS
  105. X      printf("\r\033[=14;10C\f", BlankScrn) > OutDev
  106. X    }
  107. X  }' WaitStart=$WAIT BlankScrn=$BLANK_SCR -
  108. X
  109. X  sleep $LOOPSEC
  110. Xdone
  111. SHAR_EOF
  112. chmod 0544 scrnblank || echo "restore of scrnblank fails"
  113. exit 0
  114.  
  115. -- 
  116. bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
  117.     sysop *IX BBS and Public Access UNIX
  118.     moderator of comp.binaries.ibm.pc and 80386 mailing list
  119. "Stupidity, like virtue, is its own reward" -me
  120.