Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: Screen-Blanking in a Teacher/Student-Environment
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Cocker68
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 227
Location: Germany

PostPosted: Wed Sep 22, 2004 2:43 pm    Post subject: HOWTO: Screen-Blanking in a Teacher/Student-Environment Reply with quote

HOWTO: Screen-Blanking in a Teacher/Student-Environment

In a teacher/student-environment the teacher might like to have the possibility to blank his students' screens while he is talking, because obviously computer screens are quite more attractive to the students than the teacher's boring face... :-)

The point in this solution is to remotely switch the virtual console of the client to a black one.

There has to be a common shared directory for all participating machines. (THX to member 26199)

  • On the clients (the students' machines) do the following:

    • Copy the following script to /root/bin/blankd. It will continuously be watching the common directory for a filename like the own hostname to appear.

      Code:
      #!/bin/sh
      #@@CCK 2004-09-22 15:14
      #
      #################################################################
      #
      # Purpose:
      # Blank the screen of this machine in a teacher/student-
      # -environment remotely triggered by the teacher.
      #
      # Start this script while booting, and it will watch $WATCHDIR
      # for a file named like hostname.  Screen will be blanked until
      # this file disappears.
      #
      # With Gentoo-Linux You would enable it during startup by calling
      # it in the boot-script /etc/conf.d/local.start
      #
      #################################################################

      # Directory to watch
      # Usually this is a shared directory, where the teacher (and only
      # the teacher) can place files
      #
      WATCHDIR="/home/pub/blank"

      # File, which will blank _all_ hosts.
      #
      ALLNAME="all"

      # Time in seconds the screen gets blanked again.  So it becomes
      # useless for the student to switch back to his X-Session with
      # <Ctrl-Alt>-<F7>
      #
      BLANKSLEEPTIME="2"

      # Time in seconds after which to scan for the trigger-file.
      # Specify a higher value (like 30) to reduce CPU-usage.
      #
      WORKSLEEPTIME="15"

      # Number of virtual console to switch to, to blank the screen.
      #
      VTBLANK="12"

      # Number of virtual console, where the student's X-Session
      # resides.
      #
      VTWORK="7"

      #################################################################
      # nothing to configure after this line

      export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
      MYNAME=`hostname`
      SCRIPT=`basename $0`

      if [ ! "$MYNAME" ]; then
          echo "${SCRIPT}: cannot determine my hostname.  exiting..."
          exit 1
      fi

      if [ ! -d "$WATCHDIR" ]; then
          echo "${SCRIPT}: WARNING: $WATCHDIR: no such directory"
      fi

      DONE="yes"

      while true; do
          if [ -f "${WATCHDIR}/${MYNAME}" -o -f "${WATCHDIR}/${ALLNAME}" ]; then
              chvt "$VTBLANK"
              DONE=""
              sleep "$BLANKSLEEPTIME"
          else
              if [ ! "$DONE" ]; then
                  chvt "$VTWORK"
                  DONE="yes"
              fi
              sleep "$WORKSLEEPTIME"
          fi
      done


    • edit /etc/conf.d/local.start, and put this line in it:
      Code:
      /root/bin/blankd
      So the deamon gets started with every boot.


  • On the server (the teacher's machine) do the following:

    • Copy the following script to /root/bin/blank. On invokation it will place the trigger-files into the common directory. It's also possible to group client-machines together in files.

      Code:
      #!/bin/sh
      #@@CCK 2004-09-22 14:17
      #
      #################################################################
      #
      # Purpose:
      # Blank the screen of other machines in a teacher/student-
      # -environment remotely triggered by the teacher.
      #
      # Call this script with the hostnames of machines to be blanked,
      # or call it with names of files, which contain hostnames.
      #
      # Trigger-files will be created, the corresponding script on the
      # specified machines will then blank the screen.
      #
      # Use the Option -u to unblank.
      #
      # The special name "all" will affect all machines.
      #
      #################################################################

      VERSION="1.0 2004-09-22 14:17"
      DESCR="Place files named like hostnames in a shared directory.
      Screen of those hosts will get blanked then.
      It's possible to specify groupfiles containing hostnames."

      # Directory to watch
      # Usually this is a shared directory, where the teacher (and only
      # the teacher) can place files
      #
      WATCHDIR="/home/pub/blank"

      # File, which will blank _all_ hosts.
      #
      ALLNAME="all"

      #################################################################

      SCRIPT="`basename $0`"

      try_h() {
          echo "Try '$SCRIPT -h' for more information."
      }

      usage() {
          echo "usage: $SCRIPT [ -h ] [ -V ] [ -v ] [ -u ] [ -s ] groupfile hostname..."
          echo "-h: get help"
          echo "-V: print version"
          echo "-v: be verbose"
          echo "-u: unblank instead of blank"
          echo "-s: print actual status"
          echo "groupfile: file containing hostnames to be (un)blanked. \"$ALLNAME\" has its special meaning"
          echo "hostname: hostname to be (un)blanked"
      }

      descr() {
          echo -e "$DESCR\n"
      }

      version() {
          echo -e "$SCRIPT $VERSION\nWritten by Cocker68.\nCopyright (c) Cocker68"
      }

      #################################################################

      while getopts "hVvus" OPT; do
          case $OPT in
              h) OPT_h="yes"
                  ;;
              V) OPT_V="yes"
                  ;;
              v) OPT_v="yes"
                  ;;
              u) OPT_u="yes"
                  ;;
              s) OPT_s="yes"
                  ;;
              \?) try_h
                  exit 1
                  ;;
          esac
      done

      shift `expr $OPTIND - 1`

      #################################################################

      if [ "$OPT_h" ]; then
          descr
          usage
          exit 0
      fi

      if [ "$OPT_V" ]; then
          version
          exit 0
      fi

      if [ "$OPT_v" ]; then
          VERBOSE=yes
      fi

      if [ "$OPT_u" ]; then
          UNBLANK=yes
      fi

      if [ "$OPT_s" ]; then
          STATUS=yes
          echo "hosts currently blanked:"
          ls "$WATCHDIR"
          exit 0
      fi

      if [ -z "$*" ]; then
          echo "$SCRIPT: too few arguments"
          try_h
          exit 1
      fi

      #################################################################

      if [ ! -d "$WATCHDIR" ]; then
          echo "$SCRIPT: $WATCHDIR: no such directory"
          exit 1
      fi

      while [ "$1" ]; do
          NAME="$1"

          if [ "$NAME" = "$ALLNAME" ]; then
              if [ "$UNBLANK" ]; then
                  [ "$VERBOSE" ] && echo "unblanking all"
                  rm -f ${WATCHDIR}/*
              else
                  [ "$VERBOSE" ] && echo "blanking all"
                  rm -f ${WATCHDIR}/*
                  touch "${WATCHDIR}/$ALLNAME"
              fi
              break
          fi

          if [ -f "$NAME" ]; then
              GROUP="$NAME"
              while read HOST; do
                  if [ "$UNBLANK" ]; then
                      [ "$VERBOSE" ] && echo "unblanking host $HOST"
                      rm -f "${WATCHDIR}/${HOST}"
                  else
                      [ "$VERBOSE" ] && echo "blanking host $HOST"
                      touch "${WATCHDIR}/${HOST}"
                  fi
              done < "$NAME"
          else
              HOST="$NAME"
              if [ "$UNBLANK" ]; then
                  [ "$VERBOSE" ] && echo "unblanking host $HOST"
                  rm -f "${WATCHDIR}/${HOST}"
              else
                  [ "$VERBOSE" ] && echo "blanking host $HOST"
                  touch "${WATCHDIR}/${HOST}"
              fi
          fi

          shift
      done


    • Create files like lefthalf:

      Code:
      client01
      client02
      client03


    • blank the screens of the left half of the classroom with
      Code:
      blank lefthalf


    • check the status with

      Code:
      blank -s


    • unblank all screens with
      Code:
      blank -u all




Teachers, now there exists no excuse anymore to not to migrate the classroom completely to Gentoo-Linux :-)

- Cocker :wq


Last edited by Cocker68 on Thu Sep 23, 2004 9:55 am; edited 1 time in total
Back to top
View user's profile Send private message
RexM
n00b
n00b


Joined: 12 Aug 2004
Posts: 47
Location: South Jordan, Utah

PostPosted: Wed Sep 22, 2004 3:01 pm    Post subject: Reply with quote

haha, that's a pretty cool little program, now to get that on my sister's computer ^_^
Back to top
View user's profile Send private message
Boris27
Guru
Guru


Joined: 05 Nov 2003
Posts: 562
Location: Almelo, The Netherlands

PostPosted: Wed Sep 22, 2004 3:05 pm    Post subject: Reply with quote

Good program!

(And I'm a student!)
_________________
we are microsoft, lower your firewalls and surrender your pc's. we will add your biological and technological distinctiveness to our own. your culture will adapt and service us. resistance is futile.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum