#!/bin/bash
#
# This program is designed to kill the screen blanking on the console
# I'm using it to watch the compiling from across the room
# The problem is that this effects the console and not the
# virtual console or tty. ie: set one vc - set them all
#
# setterm -blank [0-60]
### The original command for disabling the screen blanking in text mode
###echo -e "\033[9;0]" > /dev/vc/2
#BLANK_TIME="10"
CUR_CONSOLE="`tty`"
#V_CONSOLE="`tty`"
V_CONSOLE="/dev/vc/2"
#echo -ne "Starting.....\n" > $CUR_CONSOLE
#echo -ne "\$1=\"$1\"\n"
#echo -ne "$CUR_CONSOLE=\"$CUR_CONSOLE\"\n"
if [ -n "$1" -a "$1" != "" ]; then
if [ "$1" = "-h" -o "$1" = "--help" ]; then
echo -ne "Caution: this command will feed garbage"
echo -ne " to the console with bad input!!!\n"
echo -ne "\tusage: $0 [n|no|off|-h|--help]\n"
echo -ne "\t\t(where n is a cardinal number)\n"
exit 0
elif [ "$1" = "off" -o "$1" = "no" ]; then
BLANK_TIME="0"
###echo -ne "off,,,\n" > $CUR_CONSOLE
else
BLANK_TIME="$1"
###echo -ne "Blanking in ${BLANK_TIME} minutes.\n" > $CUR_CONSOLE
fi
else
BLANK_TIME="10"
###echo -ne "Using the Default of $BLANK_TIME minutes for screen blanking.\n" > $CUR_CONSOLE
fi
TMP_STR="[9;${BLANK_TIME}]"
###echo -ne "Escaping: \"$TMP_STR\"" > $CUR_CONSOLE
echo -ne "\033$TMP_STR" > $V_CONSOLE
# some problem with variable expansion
#####echo -e "\033[9;$BLANK_TIME]" > $V_CONSOLE
#echo -ne "done\n" > $CUR_CONSOLE