[comp.sys.att] You too can change your "working" icon

john@polyof.UUCP ( John Buck ) (11/18/88)

Here is a little toy for you to play with...  This program will allow you
to change the "AT&T Working" ICON that appears when your UNIX PC is
busy doing something.  'unshar' the archive below, and compile "wb.c".
I have included a couple of "sample" bitmaps for you to play with.  One
is of a horse, "horse", the other is the default AT&T ball, with the
word "working", called "saveit".

To see the current "working" icon, simply run the program without any
arguments.  To SET a new ICON, simple run the program and give it the
name "horse" (for example, "# wb horse").  Watch what happens next
time your "busy" icon lights up.

I'd be interested in seeing some of the ICONS  people come up with.  I
also have a program that makes UNIX display two icons: one when the system
is busy, and when when it is doing nothing.  I don't think I'll distribute
this because it actually goes in and changes code in /unix (/dev/kmem),
and could have adverse effects if you have a slightly different /unix
version than we do.

John Buck
john@polyof.poly.edu  john@[128.238.10.100]
trixie!polyof!john
john@polygraf.bitnet

---------------------Cut here and run through /bin/sh-------------------
echo wb.c
sed -e 's/^X//' <<"EOFwb.c" >wb.c
X/* wb -- Change "window/busy" indicator on bottom right of UNIX PC screen
X *	Copyright (c) 1988 by John Buck
X *	You may NOT include this program or its algorithm in any
X *	product designed for sale.  You can copy it for your own non-commercial
X *	use only; this entire copyright notice must be included.
X */
X#include <stdio.h>
X#include <nlist.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xstruct nlist nl[2] = {
X	{ "wbraster" },
X	{ NULL }
X};
X
X/* The "working" bitmap is 21 high by 80 wide */
Xunsigned short	wb[21][5];
Xint	fd;
X
Xmain(argc, argv)
Xchar **argv;
X{
X	FILE *fp;
X	struct stat wins, nms;
X
X	fp = NULL;
X	/* Is the window driver there? */
X	if(stat("/etc/lddrv/wind", &(wins)) == -1){
X		fprintf(stderr, "%s: Ooops -- can't stat ", argv[0]);
X		perror("/etc/lddrv/wind");
X		exit(5);
X	}
X	/* Quick name-list lookup, saves spending lots of CPU time
X	 * each invokation
X	 */
X	if(stat("/etc/lddrv/wbrast.nl", &nms) == -1 ||
X	   nms.st_mtime < wins.st_mtime ||
X	   (fp = fopen("/etc/lddrv/wbrast.nl", "r")) == NULL ||
X	   fread(&(nl[0]), sizeof (nl[0]), 1, fp) != 1){
X		if(fp) fclose(fp);
X		/* Too bad, have to do a lookup (once only?) */
X		if(nlist("/etc/lddrv/wind", nl) < 0 || nl[0].n_value <= 0){
X			fprintf(stderr, "%s: Bad namelist for %s\n", argv[0],
X				nl[0].n_name);
X			exit(2);
X		}
X		if((fp = fopen("/etc/lddrv/wbrast.nl", "w")) != NULL){
X			fwrite(&(nl[0]), sizeof (nl[0]), 1, fp);
X			fclose(fp);
X		}
X	}
X#ifdef DEBUG
X	fprintf(stdout, "wbraster @ 0x%x\n", nl[0].n_value);
X#endif
X	if((fd = open("/dev/kmem", 2)) == -1){
X		perror("/dev/kmem");
X		exit(3);
X	}
X	lseek(fd, nl[0].n_value, 0);
X	/* If args, must be a filename containing a bitmap */
X	if(argc > 1)
X		dofile(argv[1]);
X	else	{
X		/* Otherwise, just show us what is there */
X		if(read(fd, &(wb[0][0]), 21*5*(sizeof (short))) != 21*5*(sizeof(short))){
X			fprintf(stderr, "Error reading raster data\n");
X			close(fd);
X			exit(3);
X		}
X		printrast();
X	}
X	close(fd);
X	exit(0);
X}
X
Xprintrast()
X{
X	register unsigned short i, j, c, k;
X
X	for(i = 0; i < 21; i++){
X		for(j = 0; j < 5; j++){
X			c = wb[i][j];
X			for(k = 0; k < 16; k++, c >>= 1){
X				if(c & 1)
X					putchar('@');
X				else
X					putchar(' ');
X			}
X		}
X		putchar('\n');
X	}
X}
X
Xdofile(f)
Xchar *f;
X{
X	FILE *fp;
X	register unsigned short i, j, c, k;
X	register char *s;
X	char ibuf[258];
X
X	if((fp = fopen(f, "r")) == NULL){
X		fprintf(stderr, "Can't open ");
X		perror(f);
X		exit(3);
X	}
X	for(i = 0; i < 21; i++){
X		if(fgets(ibuf, 256, fp) == NULL){
X			fprintf(stderr, "Need 21 lines, only found %d\n", i);
X			exit(6);
X		}
X		s = ibuf;
X		for(j = 0; j < 5; j++){
X			c = 0;
X			for(k = 0; k < 16; k++, s++){
X				if(*s == ' '){
X					;
X				} else if(*s == '@'){
X					c |= (1<<k);
X				} else break;
X			}
X			wb[i][j] = c;
X		}
X	}
X	write(fd, &(wb[0][0]), 21*5*(sizeof (short)));
X}
EOFwb.c
echo saveit
sed -e 's/^X//' <<"EOFsaveit" >saveit
X                                                                                
X @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@         
X @                                                                    @         
X @                                                                    @         
X @                                                                    @         
X @           @@@@@@@@                                                 @         
X @             @@@@@@@@                                               @         
X @                                            @     @                 @         
X @       @@@@@@@@@@@@@@@@                     @                       @         
X @              @@@@@@@@@@    @   @  @@  @ @@ @  @ @@ @ @@  @@        @         
X @                            @   @ @  @ @@   @ @   @ @@ @ @  @       @         
X @      @@@@@@@@@@@@@@@@@@    @ @ @ @  @ @    @@    @ @  @ @  @       @         
X @             @@@@@@@@@@     @ @ @ @  @ @    @ @   @ @  @ @  @       @         
X @                             @@@   @@  @    @  @  @ @  @  @@@       @         
X @         @@@@@@@@@@@@                                       @       @         
X @           @@@@@@@@                                       @@        @         
X @                                                                    @         
X @                                                                    @         
X @                                                                    @         
X @                                                                    @         
X @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@         
EOFsaveit
echo horse
sed -e 's/^X//' <<"EOFhorse" >horse
X                           @          @                      
X                          @ @        @ @                     
X                         @   @      @   @                    
X                        @     @@@@@@     @                   
X                       @     @@@@@@       @@                 
X                       @     @@@@@@       @@@@         
X                       @  @   @@@@@   @   @@@@@            
X                       @ @@@    @@   @@@  @@ @@@            
X                       @  @@     @    @   @@@@@@@           
X                       @                  @ @@ @@@@          
X                        @                @   @@@@ @@         
X     @@@@@@@@@           @              @     @@@@@@@        
X   @@         @@          @            @       @@@@@@@@      
X  @             @        @@@@@@@@@@@@@@@@      @@@ @@@@@@@@
X @   @@@    @@   @       @@@@@@@@@@@@@@@@       @@@@@@@@ @@@@@
X @   @  @  @  @  @         @          @@@          @@@@@@@@@@@@@@
X @   @@@   @  @  @         @@@@    @@@@ @@                       @@@@@@@@@
X@    @  @  @  @   @        @   @  @   @  @@                       
X@    @@@    @@    @        @  @    @  @   @@                 
X@@               @@         @@      @@     @@ 
X @@             @@           @@@@@@@@       @@  
EOFhorse

daveb@gonzo.UUCP (Dave Brower) (11/19/88)

In article <402@polyof.UUCP> john@polyof.UUCP ( John Buck ) writes:
>Here is a little toy for you to play with...  This program will allow you
>to change the "AT&T Working" ICON that appears when your UNIX PC is
>busy doing something....

Which reminds me to ask, "what does it *mean*, anyway?"  Is it "I'm
waiting for disk i/o" or "I have no idle time" or what?

Curiously,
-dB
-- 
"It if was easy, we'd hire people cheaper than you to do it"

{sun,mtxinu,hoptoad}!rtech!gonzo!daveb		daveb@gonzo.uucp

gil@limbic.UUCP (Gil Kloepfer Jr.) (11/21/88)

In article <464@gonzo.UUCP> daveb@gonzo.UUCP (Dave Brower) writes:
|>
|>Which reminds me to ask, "what does it *mean*, anyway?"  Is it "I'm
|>waiting for disk i/o" or "I have no idle time" or what?
[It=The UNIX-pc "Working" Icon]
|>
|>{sun,mtxinu,hoptoad}!rtech!gonzo!daveb		daveb@gonzo.uucp

After fooling with this a bit and looking at when the icon appears and
disappears, I have come to the conclusion that the window driver puts
the icon on the screen at all times except when a process connected
to the "current" window is blocking for terminal input.  At all other
times, the icon is on.  You will notice that it will come on during
a "sleep" command in the shell, but not if you simply start a subprocess
with output going to the terminal.  Even if the machine is "working" its
brains out...that icon won't come on if something is waiting for input
from the current window.

The idea of which window is "current" in this context is the window that
the keyboard is currently attached to.

Any counter-ideas to this theory are welcome.  It's the only explanation
I can come up with.  If anyone else knows for sure what happens, that's
even better :-)

------
Gil Kloepfer, Jr.          U-Net: {decuac,boulder,talcott,sbcs}!icus!limbic!gil
ICUS Software Systems      Voice: (516) 968-6860 [H]   (516) 746-2350 x219 [W]
P.O. Box 1                 Internet:  gil@icus.islp.ny.us
Islip Terrace, NY  11752   "Life's a ...  well, you know..."

ditto@cbmvax.UUCP (Michael "Ford" Ditto) (11/22/88)

In article <464@gonzo.UUCP> daveb@gonzo.UUCP (Dave Brower) writes:
>In article <402@polyof.UUCP> john@polyof.UUCP ( John Buck ) writes:
>> [ ... ] the "AT&T Working" ICON that appears when your UNIX PC is
>>busy doing something....
>
>Which reminds me to ask, "what does it *mean*, anyway?"  Is it "I'm
>waiting for disk i/o" or "I have no idle time" or what?

The "working" icon appears when no process is currently reading from the
selected window.  You can demonstrate this by typing "sleep 5;read foo"
to the shell.  When the "read" is executed the icon will go away.
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford@kenobi.cts.com
- The Unix Programmer's Manual,		...!sdcsvax!crash!elgar!ford
  2nd Edition, June, 1972.		ditto@cbmvax.commodore.com