home *** CD-ROM | disk | FTP | other *** search
- From: davidsen@sixhub.UUCP (Wm E. Davidsen Jr)
- Newsgroups: alt.sources
- Subject: Xenix screenblanker - updated, with docs
- Message-ID: <2151@sixhub.UUCP>
- Date: 23 Oct 90 23:45:50 GMT
-
-
- The first post was pretty ugly, here's one with a man page and
- slightly better command interface. This blanks console screens on Xenix
- after a period of inactivity.
-
- #!/bin/sh
- # shar: Shell Archiver (v1.27)
- #
- # Run the following text with /bin/sh to create:
- # scrnblank.1
- # scrnblank
- #
- sed 's/^X//' << 'SHAR_EOF' > scrnblank.1 &&
- X.TH scrnblank L local
- X.SH NAME
- Xscrnblank \- blank console after a period of inactivity
- X.SH SYNOPSIS
- Xscrnblank [ idle_mins [ inverval_sec ] ]
- X.SH DESCRIPTION
- XChecks periodically to see if all virtual consoles have been inactive
- Xfor a length of time. If so the screen is blanked.
- X
- XIn your system rc file for user daemons (/etc/rc.d/7 directory) you can
- Xadd the command "scrnblank &".
- X.SH EXAMPLES
- X scrnblank
- X scrnblank 20
- X scrnblank 1 20
- X.SH LIMITATIONS
- XThis program requires a virtual console dedicated as a blank screen.
- XThis is not usually a problem.
- X.SH FILES
- X/etc/rc.d/7/
- X.SH AUTHOR
- XBill Davidsen, davidsen@crdos1.crd.ge.com
- X.SH Copyright
- XCopyright 1990 by Bill Davidsen, all rights reserved. May be freely used
- Xand distributed.
- SHAR_EOF
- chmod 0644 scrnblank.1 || echo "restore of scrnblank.1 fails"
- sed 's/^X//' << 'SHAR_EOF' > scrnblank &&
- X#!/bin/sh
- X
- X# blank screen for Xenix @(#)scrnblank - v1.3, 10/23/90 19:22:10
- X
- X# ================ customize begins
- X# this is the screen number for the blank screen
- X# it should not be in use, preferably without a getty,
- X# since the cursor is not restored. ie. tty07 would be 7
- XBLANK_SCR=7
- X#=============== end of customize features
- X
- X# calling sequence:
- X# scrnblank [mins [interval]]
- X# Checks every {interval} seconds (default 60) to see if all console
- X# screens have been idle for {mins} minutes (default 5), and switches to
- X# the virtual screen selected below and blanks it.
- X
- X# This is the time to wait in minutes.
- X# It may be set from the command line, too
- Xif [ $# -ge 1 ]
- Xthen WAIT=$1
- Xelse WAIT=5
- Xfi #
- X
- X# this is the interval at which to test
- Xif [ $# -ge 2 ]
- Xthen LOOPSEC=$2
- Xelse LOOPSEC=60
- Xfi #
- X
- X# Logic:
- X# the output of "who -u" is scanned to see if all console
- X# logins are over N minutes unused. Then the screen is blanked
- X# by setting cursor off and doing a clear screen.
- X# This program must be run from a tty
- X
- Xwhile true; do
- X who -u |
- X awk '
- X $2 ~ /tty[01][0-9]/ {
- X # Get the time field
- X time=substr($0, 38, 5)
- X if (time == "old") continue
- X split(time, xtime, ":")
- X idle = 60*xtime[1] + xtime[2]
- X if (WaitStart < idle) continue
- X Active = 1
- X }
- X
- X END {
- X # really ugly way to change screens
- X if (!Active) {
- X # form the device name
- X OutDev=sprintf("/dev/tty%02d", BlankScrn)
- X # switch to the screen for blank use
- X printf("\r\033[%02dz", BlankScrn-1) > OutDev
- X # cursor off, CLS
- X printf("\r\033[=14;10C\f", BlankScrn) > OutDev
- X }
- X }' WaitStart=$WAIT BlankScrn=$BLANK_SCR -
- X
- X sleep $LOOPSEC
- Xdone
- SHAR_EOF
- chmod 0544 scrnblank || echo "restore of scrnblank fails"
- exit 0
-
- --
- bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
- sysop *IX BBS and Public Access UNIX
- moderator of comp.binaries.ibm.pc and 80386 mailing list
- "Stupidity, like virtue, is its own reward" -me
-