[comp.unix.i386] running setcolor script on bootup

larry@nstar.uucp (Larry Snyder) (07/11/90)

I am running 386/ix 2.2 and have a script that controls the 
colors on my various console windows and enables scrolling -
yet placing this script in /etc/rc.d doesn't work since the
consoles are not initiated as of yet - where could I put this
script so that it executes right after the various consoles
are initialized?

-- 
      Larry Snyder, Northern Star Communications, Notre Dame, IN USA 
            uucp: iuvax!ndmath!nstar!larry  -or-  larry@nstar
            Public Access Unix Site (219) 289-3745 (multiline)

gary@sci34hub.UUCP (Gary Heston) (07/12/90)

In article <1990Jul11.123256.939@nstar.uucp> larry@nstar.uucp (Larry Snyder) writes:
>yet placing this script in /etc/rc.d doesn't work since the
>consoles are not initiated as of yet - where could I put this
>script so that it executes right after the various consoles
>are initialized?

/etc/rc.d is a holding place for initializing scripts. They're executed
from /etc/rc0.d, or /etc/rc2.d, where they're linked to start or kill
names. Link your script in rc.d to rc2.d/S95script, and init will
execute it towards the end of setting up init level 2. The names in
the numbered rc.d directories follow the form:

   {KS}[00-99]name

Where:

	K or S indicates Kill or Start the process, daemon, etc.

	00-99 is a two-digit sequence number that init uses to 
		decide when each of the scripts is run.

	name  is a reference name for your convenience (acct, 
		sendmail, lp, etc.).

If you do a ls -i of /etc/rc.d and /etc/rc2.d, you'll find that
several are linked together.


-- 
    Gary Heston     { uunet!sci34hub!gary  }    System Mismanager
   SCI Technology, Inc.  OEM Products Department  (i.e., computers)
"The esteemed gentleman says I called him a liar. That's true, and I
regret it." Retief, a character created by Keith Laumer.

robert@towers.UUCP (Robert Hoquim) (07/13/90)

larry@nstar.uucp (Larry Snyder) writes:

>I am running 386/ix 2.2 and have a script that controls the
>colors on my various console windows and enables scrolling -
>yet placing this script in /etc/rc.d doesn't work since the
>consoles are not initiated as of yet - where could I put this
>script so that it executes right after the various consoles
>are initialized?

Try putting it in your user .profile or in the /etc/profile (master pre- 
profile file) since they are activated after the consoles are set up.
-- 
  Robert Hoquim                                 Small Systems Specialists
  (317)-255-6807                                8500 N. Meridian
..!nstar!towers!robert                          Indianapolis, IN.  46260

david@csource.oz.au (david nugent) (07/13/90)

In <1990Jul11.123256.939@nstar.uucp> larry@nstar.uucp (Larry Snyder) writes:

>I am running 386/ix 2.2 and have a script that controls the 
>colors on my various console windows and enables scrolling -
>yet placing this script in /etc/rc.d doesn't work since the
>consoles are not initiated as of yet - where could I put this
>script so that it executes right after the various consoles
>are initialized?

Something like the following can be placed in /etc/rc.d/<whatever>

	TERM=AT386;export TERM
	setcolor -s On
	
	setcolor -f lgreen,black >/dev/vt01
	setcolor -f lgreen,black >/dev/vt02
	.
	. etc.
	.
	setcolor -f yellow,black >/dev/console

The hardware scrolling option is global and stays active in all
virtual terminals once it's enabled in any of them.  With colors,
setcolor just outputs ANSI sequences, but (which is a little silly)
tests only the controlling TTY for an AT386 tty type.

I complicate the picture a bit, since I prefer 43 line EGA mode
on all virtual terminals.  This requires a small program to open
them one by one and do an ioctl() to set 43 line mode, then use
setcolor to adjust the cursor size.

	v43all
	setcolor -c 6,7 >/dev/vt01
	.
	. etc.
	.

v43all goes something like this:

/* ------------------------------- cut here ----------------------------- */

/*
**	v43all.c
**	Program to run at boot time on ISC 386/ix
**	to flip all virtual terminals into 43line EGA mode
**
**	David Nugent, donated to public domain
*/

# include <stdio.h>
# include <fcntl.h>
# include <sys/types.h>
# include <sys/at_ansi.h>
# include <sys/kd.h>
# include <errno.h>


int main (int argc, char *argv[])
{
	int		vt;
	int		fd;
	char	*dev, vtdev[256];

	dev = vtdev;
	for (vt = 0; vt++ < 8; )
		{
		if (vt < 8)
			{
			sprintf (vtdev, "/dev/vt%02u", vt);
			}
		else
			dev = "/dev/console";
		fd = open (dev, O_WRONLY);
		if (fd == -1)
			{
			fprintf (stderr, "Error %d opening %s\n", errno, dev);
			continue;
			}
		switch (ioctl (fd, CONS_CURRENT, 0))
			{
			case -1:
			case KD_MONO:
			case KD_HERCULES:
			case KD_CGA:
				fputs ("Incompatible monitor type\n", stderr);
				break;
			case KD_EGA:
			case KD_VGA:
				ioctl (fd, SW_ENHC80x43, 0);
				break;
			}
		}

	return 0;
}


/* ------------------------------- cut here ----------------------------- */


After initially experimenting with this under ISC 2.0.1 & 2.0.2,
I'm certainly happy that ISC have fixed the problem where it didn't
preserve modes across virtual terminals.  Now when you flip vt's
the screen mode changes accordingly (as it should).  I'm also glad
they've put in the ^[= sequences which makes setcolor possible.

david

-- 
_______________________________________________________________________________
 Unique Computing Pty Ltd  Melbourne  Australia  -  Communications Specialists 
        david@csource.oz.au    3:632/348@fidonet    28:4100/1@signet           

david@csource.oz.au (david nugent) (07/13/90)

>I complicate the picture a bit, since I prefer 43 line EGA mode
>on all virtual terminals.  This requires a small program to open
>them one by one and do an ioctl() to set 43 line mode, then use
>setcolor to adjust the cursor size.

>	v43all
>	setcolor -c 6,7 >/dev/vt01
>	.
>	. etc.
>	.


I should also add that I set the environment variable LINES=43 in
the /etc/profile script after checking that the controlling tty is
/dev/vt?? or /dev/console.  This allows terminfo (and all the
software using it) to take advantage of the full screen.


david
-- 
_______________________________________________________________________________
 Unique Computing Pty Ltd  Melbourne  Australia  -  Communications Specialists 
        david@csource.oz.au    3:632/348@fidonet    28:4100/1@signet