My screen saver for a plain session


View Poll Results: Do U think this will be usable?
If I can get the thing to work! 2 66.67%
Perhaps 1 33.33%
NEVER! 0 0%
Yes, with some addons 0 0%
Multiple Choice Poll. Voters: 3. This poll is closed

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting My screen saver for a plain session
# 1  
Old 01-09-2006
Bug My screen saver for a plain session

Good day. Smilie

I don't know exactly where or how to post this kind of stuff, but I though I'd like to have a look at my "Screen Saver" in progress. Comments welcome.

This uses bash. Just copy and pase into any file. Make o+x and run. Feel free to edit and change all u like.

Thanks.

Code:
#!/usr/bin/bash

# DEFINE COLORS
BLUE='\e[1;34m'
RED='\e[1;31m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
PUR='\e[1;35m'

# DEFINE SCREEN SETTINGS
TOP_OF_SCREEN=1
BOTTOM_OF_SCREEN=40
LEFT_OF_SCREEN=1
RIGHT_OF_SCREEN=100


MIDDLE_OF_SCREEN_X=`expr $LEFT_OF_SCREEN + $RIGHT_OF_SCREEN` MIDDLE_OF_SCREEN_Y=`expr $TOP_OF_SCREEN + $BOTTOM_OF_SCREEN`

MIDDLE_OF_SCREEN_X=`expr $MIDDLE_OF_SCREEN_X / 2` MIDDLE_OF_SCREEN_Y=`expr $MIDDLE_OF_SCREEN_Y / 2`


# DEFINE WORM BODY
BOD1="O"
BOD2="@"
BOD3="@"
BOD4="@"
BOD5="@"
BOD6="@"
BOD7="@"
BOD8="."


# DEFINE START POSITION
B1X=$MIDDLE_OF_SCREEN_X
B1Y=$MIDDLE_OF_SCREEN_Y
B2X=$MIDDLE_OF_SCREEN_X
B2Y=$MIDDLE_OF_SCREEN_Y
B3X=$MIDDLE_OF_SCREEN_X
B3Y=$MIDDLE_OF_SCREEN_Y
B4X=$MIDDLE_OF_SCREEN_X
B4Y=$MIDDLE_OF_SCREEN_Y
B5X=$MIDDLE_OF_SCREEN_X
B5Y=$MIDDLE_OF_SCREEN_Y
B6X=$MIDDLE_OF_SCREEN_X
B6Y=$MIDDLE_OF_SCREEN_Y
B7X=$MIDDLE_OF_SCREEN_X
B7Y=$MIDDLE_OF_SCREEN_Y
B8X=$MIDDLE_OF_SCREEN_X
B8Y=$MIDDLE_OF_SCREEN_Y





function DRAW_WORM {
tput cup $B1Y $B1X; echo -e "${BLUE} $BOD1"
tput cup $B2Y $B2X; echo -e "${RED} $BOD2"
tput cup $B3Y $B3X; echo -e "${GREEN} $BOD3"
tput cup $B4Y $B4X; echo -e "${YELLOW} $BOD4"
tput cup $B5Y $B5X; echo -e "${PUR} $BOD5"
tput cup $B6Y $B6X; echo -e "${BLUE} $BOD6"
tput cup $B7Y $B7X; echo -e "${RED} $BOD7"
tput cup $B8Y $B8X; echo -e "${GREEN} $BOD8"
}

function GET_DIRECTION {
limit=9
R1=99999
seed1=$RANDOM
seed=`nawk 'BEGIN {srand('"$seed1"');print int(rand() * '"$R1"') }'`; DIR=`nawk 'BEGIN {srand('"$seed"');print int(rand() * '"$limit"') }'`; }

function MOVE_WORM {
GET_DIRECTION;

#MOVES THE REST OF THE BODY
B8X=$B7X
B8Y=$B7Y

B7X=$B6X
B7Y=$B6Y

B6X=$B5X
B6Y=$B5Y

B5X=$B4X
B5Y=$B4Y

B4X=$B3X
B4Y=$B3Y

B3X=$B2X
B3Y=$B2Y

B2X=$B1X
B2Y=$B1Y


# MOVE HEAD
MOVE="FALSE"
case $DIR in
0) TEST=`expr $B1X - 1`; TEST2=`expr $B1Y - 1`;
   if [ $TEST -gt $LEFT_OF_SCREEN ]; then MOVE="TRUE"; fi;
   if [ $MOVE = "TRUE" ]; then if [ $TEST2 -gt $TOP_OF_SCREEN ]; then B1X=$TEST; B1Y=$TEST2; fi; fi;;
1) TEST=`expr $B1Y - 1`; if [ $TEST -gt $TOP_OF_SCREEN ]; then B1Y=$TEST; fi;;
2) TEST=`expr $B1X + 1`; TEST2=`expr $B1Y - 1`;
   if [ $TEST -lt $RIGHT_OF_SCREEN ]; then MOVE="TRUE"; fi;
   if [ $MOVE = "TRUE" ]; then if [ $TEST2 -gt $TOP_OF_SCREEN ]; then B1X=$TEST; B1Y=$TEST2; fi; fi;;
3) TEST=`expr $B1X + 1`; if [ $TEST -lt $RIGHT_OF_SCREEN ]; then B1X=$TEST; fi;;
4) TEST=`expr $B1X + 1`; TEST2=`expr $B1Y + 1`;
   if [ $TEST -lt $RIGHT_OF_SCREEN ]; then MOVE="TRUE"; fi;
   if [ $MOVE = "TRUE" ]; then if [ $TEST2 -lt $BOTTOM_OF_SCREEN ]; then B1X=$TEST; B1Y=$TEST2; fi; fi;;
5) TEST=`expr $B1Y + 1`; if [ $TEST -lt $BOTTOM_OF_SCREEN ]; then B1Y=$TEST; fi;;
6) TEST=`expr $B1X - 1`; TEST2=`expr $B1Y + 1`;
   if [ $TEST -gt $LEFT_OF_SCREEN ]; then MOVE="TRUE"; fi;
   if [ $MOVE = "TRUE" ]; then if [ $TEST2 -lt $BOTTOM_OF_SCREEN ]; then B1X=$TEST; B1Y=$TEST2; fi; fi;;
7) TEST=`expr $B1X - 1`; if [ $TEST -gt $LEFT_OF_SCREEN ]; then B1X=$TEST; fi;; esac; 

#tput cup 3 40; printf $DIR

}

function DRAW_BORDER {
#BOTTOM_OF_SCREEN=40
#LEFT_OF_SCREEN=10
#RIGHT_OF_SCREEN=100
#TOP_OF_SCREEN=10

#DRAW THE LEFT BORDER
BEGIN=$TOP_OF_SCREEN
while [ $BEGIN -lt $BOTTOM_OF_SCREEN ]; do tput cup $BEGIN $LEFT_OF_SCREEN ; echo @; BEGIN=`expr $BEGIN + 1`; done;

#RIGHT OF BORDER
BEGIN=$TOP_OF_SCREEN
while [ $BEGIN -lt $BOTTOM_OF_SCREEN ]; do tput cup $BEGIN $RIGHT_OF_SCREEN ; echo @; BEGIN=`expr $BEGIN + 1`; done;

#BOTTOM OF BORDER
BEGIN=$LEFT_OF_SCREEN
while [ $BEGIN -lt $RIGHT_OF_SCREEN ]; do tput cup $BOTTOM_OF_SCREEN $BEGIN; echo @; BEGIN=`expr $BEGIN + 1`; done;

#TOP OF BORDER
BEGIN=$LEFT_OF_SCREEN
while [ $BEGIN -lt $RIGHT_OF_SCREEN ]; do tput cup $TOP_OF_SCREEN $BEGIN; echo @; BEGIN=`expr $BEGIN + 1`; done;



}



# THIS IS THE MAIN SCRIPT
clear;
DRAW_BORDER;
while true; do
DRAW_WORM;
MOVE_WORM;
#sleep 1;
done;


Last edited by RTM; 01-09-2006 at 06:52 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Cannot eliminate screen blank, lock or saver or whatever it's called...

Hi all, I'm running CentOS 7. When the machine is left alone for a few minutes, a screen saver or blanker or something comes up with a clock and date on it. You have to swipe this to get back to the desktop. I'm trying desperately to get rid of this so that it never comes up. No matter how long... (1 Reply)
Discussion started by: marmotking
1 Replies

2. Windows & DOS: Issues & Discussions

Screen saver mode at work

Hi, At work, the PC Windows 7 goes to screen saver mode after 10 minutes. I don't have access to change that. It's grayed out for me. After 10 minutes, the IM will say " AWAY" and my email status will say " AWAY ". Email and IM both are from Microsoft. My question is there any work... (2 Replies)
Discussion started by: samnyc
2 Replies

3. Red Hat

command line tool to disable screen lock and/or screen saver

Hi, I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies

4. UNIX for Dummies Questions & Answers

Screen Saver for LINUX - ROOT

Good Morning. I have a question about screen savers in LINUX especially CENTOS. I don't seem to have a problem setting the screen saver with a password required for the root account(version 5.3). I'm told earlier versions you could not set it for. I was wondering if newer versions of LINUX had... (1 Reply)
Discussion started by: ejjones
1 Replies

5. Solaris

screen saver

I am using solaris 10 x86, i am trying to create my own sreensavers using the pictures in my folder. pls can someone tell on how to go about this (1 Reply)
Discussion started by: seyiisq
1 Replies

6. Solaris

Screen Saver Resolution

I am using sun solaris machine i have given the specs of that machine given below Name of athe Platform : SUNW,Ultra-5_10 Machiene hardware :sun4u Processor Type :sparc Operating system : solaris 10 Monitory TYpe : SAMSUNG Sync Master... (2 Replies)
Discussion started by: ambavaram
2 Replies

7. UNIX and Linux Applications

screen saver in UNIX~~~~~~HELP NEEDED

One of my Sun Box running SUNOS 4.1.3_U1, the screen saver in turn on. if there anyway to disable the screen saver? Thanks (0 Replies)
Discussion started by: AirWalker83
0 Replies

8. Solaris

how to remove the screen saver on solaris box

Hi, :) I have a Sun 3500 box with solaris 8 in it. I dont know who had installed the screen saver. every 5 minutes the screen saver comes up. Its annoying when we are working on the console. Can any one tell what i can do to remove the screen saver. Thanks in advance. Ishila. :) (4 Replies)
Discussion started by: ishila
4 Replies

9. UNIX for Dummies Questions & Answers

Screen saver

Can any one help me knowing how to do screen saver after certain time ? Thanks (3 Replies)
Discussion started by: Hegazy Mahdy
3 Replies
Login or Register to Ask a Question