steve@ivucsb.UUCP (Steve Lemke) (02/06/89)
Has anyone got a screen dimmer that works on the console in A/UX? Has anyone experimented with using regular Mac OS ones dumped into the SASH partition's System Folder? I tried to boot with SuperClock in the system folder and ran into problems, so I haven't tried any screen dimmer inits yet. Anything would be fine - a daemon of some sort or an init for the Mac partition. Any ideas? (Actually, I'm still looking for something to write the time into the menu bar for me - any ideas about that would be appreciated, too). (I just tested "Dimmer", and although A/UX boots up, it doesn't work.) ----- Steve Lemke ------------------- "MS-DOS (OS/2, etc.) - just say no!" ----- Internet: lemke@apple.ucsb.edu AppleLink: Lemke ----- Or try: pyramid!nessus!ivucsb!steve CompuServe: 73627,570 ----- Quote: "What'd I go to college for?" "You had fun, didn't you?"
aem@ibiza.Miami.Edu (a.e.mossberg) (02/13/89)
In <523@ivucsb.UUCP>, <lemke@apple.ucsb.edu> wrote: >Has anyone got a screen dimmer that works on the console in A/UX? Has >anyone experimented with using regular Mac OS ones dumped into the SASH >partition's System Folder? I tried to boot with SuperClock in the system >folder and ran into problems, so I haven't tried any screen dimmer inits >yet. Anything would be fine - a daemon of some sort or an init for the >Mac partition. Any ideas? (Actually, I'm still looking for something to >write the time into the menu bar for me - any ideas about that would be >appreciated, too). This has been posted before. It is a screen dimmer by Earl Wallace at Apple. We use it here on our macs. /**************************************************************************** * * dim.c * * Earl Wallace, Apple Computer * ****************************************************************************/ #include <stdio.h> #include <malloc.h> #include <sys/stropts.h> #include <sys/video.h> #include <sys/signal.h> #include <sys/var.h> #include <a.out.h> #ifdef BSD_SIGNALS # include <compat.h> #endif /* BSD_SIGNALS */ #define BACKGROUND 0 #define FOREGROUND 1 #define FD 1 /* file desc of console */ #define MEGABYTE 1024*1024 extern int strap(); extern int sioctl(); extern int SetColor(); extern int GetVideoSize(); extern int GetUvar(); extern int mclock(); extern int GetVideoAddress(); extern int GetVideoPixsize(); extern char *malloc(); extern char *optarg; extern int optind, opterr; extern void SaveScreen(); #ifdef BSD_SIGNALS struct sigvec svec; #endif /* BSD_SIGNALS */ struct video_size vpixsize; struct var var; long vsize[2]; unsigned int segment_size; unsigned int page_size; int pregion; unsigned int vram_size; unsigned char *vram_virt; unsigned int *vram; unsigned char *vram_phys; char ans[80]; int dim_time = 300; /* default: 300 seconds */ int dim_val = 50; /* dim value */ unsigned int *screen; int screen_size; int WeAreTheDimWits; int errflg; int colmax; /* vpixsize.pix_scr_x / 32 */ int linemax; /* vpixsize.pix_scr_y */ int nextline; /* vpixsize.pix_mem_x / 32 */ /*==========================================================================* * * main * *==========================================================================*/ main(argc, argv, envp) int argc; char *argv[], *envp[]; { register int offset1, offset2, line, col; register unsigned int *v, *s; register unsigned int byte; setbuf(stderr, NULL); /* * parse command line */ while ((col=getopt(argc, argv, "t:p:")) != EOF) { switch(col) { case 't': dim_time = atoi(optarg); break; case 'p': dim_val = (255 * atoi(optarg)) / 100; break; case '?': ++errflg; } } if (errflg) { fprintf(stderr, "%s: Usage: %s [-t dim_time] [-p dim_percentage]\n", argv[0], argv[0]); exit(1); } #ifdef BSD_SIGNALS if (setcompat(getcompat()|COMPAT_BSDSIGNALS|COMPAT_SYSCALLS) < 0) { fprintf(stderr, "setcompat() failed - "); perror(""); exit(1); } /* * The signal handler and mask are set */ svec.sv_handler = strap; /* signal handling function */ svec.sv_mask = 0; /* don't block any signals */ svec.sv_onstack = 0; /* don't use signal stack */ if (sigvec(SIGINT, &svec, (struct sigvec *)0) < 0) { fprintf(stderr, "sigvec() SIGINT failed - "); perror(""); exit(1); } if (sigvec(SIGQUIT, &svec, (struct sigvec *)0) < 0) { fprintf(stderr, "sigvec() SIGQUIT failed - "); perror(""); exit(1); } if (sigvec(SIGTERM, &svec, (struct sigvec *)0) < 0) { fprintf(stderr, "sigvec() SIGTERM failed - "); perror(""); exit(1); } if (sigsetmask(0) < 0) { fprintf(stderr, "sigsetmask() failed - "); perror(""); exit(1); } #else /* NOT BSD_SIGNALS */ signal(SIGINT, strap); /* catch keyboard break/interrupt */ signal(SIGQUIT, strap); /* catch keyboard quit signal */ signal(SIGTERM, strap); /* catch software term. signal */ #endif /* BSD_SIGNALS */ if (!isatty(0)) setpgrp(); /* break from console process group */ if (GetVideoSize(FD, vsize) < 0) exit(1); if (GetVideoAddress(FD, &vram_phys) < 0) exit(1); if (GetVideoPixsize(FD, &vpixsize) < 0) exit(1); if (GetUvar(&var) < 0) exit(1); segment_size = 1<<var.v_segshift; page_size = 1<<var.v_pageshift; pregion = 0; vram_virt = (unsigned char *) (5*MEGABYTE); vram_size = 1*MEGABYTE; if ((int)vram_virt % (int)segment_size) { fprintf(stderr, "virtual address 0x%x (%d) not on segment ", vram_virt, vram_virt); fprintf(stderr, "boundary.\nSegment size is 0x%x (%d).\n", segment_size, segment_size); exit (1); } if ((int)vram_size % (int)page_size) { fprintf(stderr, "Address space size 0x%x (%d) not a multiple ", vram_size, vram_size); fprintf(stderr, "of page size.\nPage size is 0x%x (%d).\n", page_size, page_size); exit (1); } if (phys(pregion, vram_virt, vram_size, vram_phys) < 0) { fprintf(stderr, "%s: phys() failed - ", argv[0]); perror(""); exit (1); } /* I bet you want to know who uses vram, eh? */ vram = (unsigned int *) (((unsigned int)vram_virt & ~page_size) + 32); /* allocate enough memory for a screen buffer save */ screen_size = vpixsize.pix_scr_x * vpixsize.pix_scr_y; screen_size /= 8; /* convert bits to bytes */ if ((screen=(unsigned int *)malloc(screen_size)) == NULL) { fprintf(stderr, "%s: malloc(%d) failed - ", argv[0], screen_size); exit (1); } colmax = vpixsize.pix_scr_x / 32; linemax = vpixsize.pix_scr_y; nextline = vpixsize.pix_mem_x / 32; v = vram; s = screen; while (1) { SaveScreen(s, v); if (WeAreTheDimWits) { sleep(1); if (CmpScreen(s, v) < 0) { /* brighten screen... */ int xx; for (xx=dim_val; xx < 255; xx += 5) SetColor(FD, xx, xx, xx, 0, 0, 0); WeAreTheDimWits = 0; } } else { sleep(dim_time); if (CmpScreen(s, v) == 0) { /* dim screen... */ int xx; for (xx=255; xx > dim_val; --xx) SetColor(FD, xx, xx, xx, 0, 0, 0); ++WeAreTheDimWits; } } } } /*==========================================================================* * * SaveScreen * *==========================================================================*/ void SaveScreen(to, from) register unsigned int *to, *from; { register int line, col, offset1, offset2; for (line=0; line < linemax; ++line) { offset1 = line * nextline; /* visible and invisible parts */ offset2 = line * colmax; /* visible part only */ for (col=0; col < colmax; ++col) { to[col+offset2] = from[col+offset1]; } } } /*==========================================================================* * * CmpScreen * *==========================================================================*/ int CmpScreen(s1, s2) register unsigned int *s1, *s2; { register int line, col, offset1, offset2; for (line=0; line < linemax; ++line) { offset1 = line * nextline; /* visible and invisible parts */ offset2 = line * colmax; /* visible part only */ for (col=0; col < colmax; ++col) { if (s1[col+offset2] != s2[col+offset1]) return (-1); /* mismatch */ } } return(0); /* matched */ } /*==========================================================================* * * SetColor * *==========================================================================*/ int SetColor(fd, b_red, b_green, b_blue, f_red, f_green, f_blue) register int fd, b_red, b_green, b_blue, f_red, f_green, f_blue; { struct video_color vcolor; register struct video_color *c = &vcolor; c->color[BACKGROUND].red = b_red<<8; c->color[BACKGROUND].green = b_green<<8; c->color[BACKGROUND].blue = b_blue<<8; c->color[FOREGROUND].red = f_red<<8; c->color[FOREGROUND].green = f_green<<8; c->color[FOREGROUND].blue = f_blue<<8; if (sioctl(fd, VIDEO_SETCOLOR, -1, sizeof vcolor, c) < 0) { fprintf(stderr, "SetColor: sioctl() failed - "); perror(""); return (-1); } return (0); } /*==========================================================================* * * sioctl * *==========================================================================*/ int sioctl(fd, cmd, timout, len, dp) int fd, cmd, timout, len; char *dp; { static struct strioctl sio; register struct strioctl *s = &sio; s->ic_cmd = cmd; s->ic_timout = timout; s->ic_len = len; s->ic_dp = dp; return (ioctl(fd, I_STR, s)); } /*==========================================================================* * * strap (used with BSD and SYSV signals) * *==========================================================================*/ int strap(sno) int sno; { /* set background to white and foreground to black */ SetColor(FD, 255, 255, 255, 0, 0, 0); /* refreh the console screen */ /* sioctl(FD, VIDEO_REFRESH, -1, 0, NULL); */ /* fprintf(stderr, "Caught Signal %d - Program Aborted.\n", sno); */ exit (-sno); } /*==========================================================================* * * GetVideoSize * * The argument "vs" is a pointer to an allocated array of two longs. * The array will be filled with information about the size of the display. * The first array long is the number of characters, in width, of the * display. The second long in the array is the number of characters, in * height, of the display. * *==========================================================================*/ GetVideoSize(fd, vs) int fd; long *vs; { if (sioctl(fd, VIDEO_SIZE, -1, 2 * sizeof *vs, vs) < 0) { fprintf(stderr, "GetVideoSize: sioctl() failed - "); perror(""); return (-1); } return (0); } /*==========================================================================* * * GetVideoAddress * * The argument "va" is a pointer to an allocated unsigned int. * This unsigned int will be filled with physical address of the video RAM on * the Video Card. *==========================================================================*/ int GetVideoAddress(fd, va) int fd; unsigned int *va; { if (sioctl(fd, VIDEO_ADDR, -1, sizeof va, va) < 0) { fprintf(stderr, "GetVideoAddress: sioctl() failed - "); perror(""); return (-1); } return (0); } /*==========================================================================* * * GetVideoPixsize * *==========================================================================*/ int GetVideoPixsize(fd, vp) int fd; struct video_size *vp; { if (sioctl(fd, VIDEO_PIXSIZE, -1, sizeof *vp, vp) < 0) { fprintf(stderr, "GetVideoPixsize: sioctl() failed - "); perror(""); return (-1); } return (0); } /*==========================================================================* * * GetUvar * * The argument "v" is a pointer to an allocated var structure. * This structure will be filled with information on the kernel. * *==========================================================================*/ int GetUvar(v) struct var *v; { if (uvar(v) < 0) { fprintf(stderr, "GetUvar: uvar() failed - "); perror(""); return (-1); } return (0); } a.e.mossberg aem@mthvax.miami.edu MIAVAX::AEM (Span) aem@umiami.BITNET (soon) It is easier to be a lover than a husband, for the same reason that it is more difficult to show a ready wit all day than to say a good thing occasionally. - Honore de Balzac
dwb@Apple.COM (David W. Berry) (02/14/89)
In article <523@ivucsb.UUCP> lemke@apple.ucsb.edu writes: >Has anyone got a screen dimmer that works on the console in A/UX? Has >anyone experimented with using regular Mac OS ones dumped into the SASH >partition's System Folder? I tried to boot with SuperClock in the system >folder and ran into problems, so I haven't tried any screen dimmer inits >yet. Anything would be fine - a daemon of some sort or an init for the >Mac partition. Any ideas? (Actually, I'm still looking for something to >write the time into the menu bar for me - any ideas about that would be >appreciated, too). 1. Earl Wallace here at Apple wrote a screen dimmer specifically for A/UX. It was posted some time back, if desired I can get him to post it again. Hey Earl, you listening? 2. When A/UX is running it uses it's own system folder, separate from the one in the sash partition. The default is /usr/lib/mac, but that can be overridden by setting the TBSYSTEM environment variable. 3. A/UX does not currently support INIT's and while CDEV's are supported CDEV's such as moire won't work because they rely on the unsupported INIT 31 mechanism to install code at boot time. This also means that you probably won't be able to find a menu bar clock since they all install as an INIT. Opinions: MINE, ALL MINE! (greedy evil chuckle) David W. Berry (A/UX Toolbox Engineer) apple!dwb@sun.com dwb@apple.com 973-5168@408.MaBell
barad@bourbon.ee.tulane.edu (Herb Barad) (02/17/89)
In article <1401@umbio.MIAMI.EDU* aem@Mthvax.Miami.Edu (a.e.mossberg) writes:
*In <523@ivucsb.UUCP*, <lemke@apple.ucsb.edu* wrote:
**Has anyone got a screen dimmer that works on the console in A/UX? Has
**anyone experimented with using regular Mac OS ones dumped into the SASH
**partition's System Folder? I tried to boot with SuperClock in the system
**folder and ran into problems, so I haven't tried any screen dimmer inits
**yet. Anything would be fine - a daemon of some sort or an init for the
**Mac partition. Any ideas? (Actually, I'm still looking for something to
**write the time into the menu bar for me - any ideas about that would be
**appreciated, too).
*
*This has been posted before. It is a screen dimmer by Earl Wallace
*at Apple. We use it here on our macs.
This is a nice dimmer and in fact we use it on our A/UX Macs.
However, it must be run manually from the console once after booting.
It cannot be run automatically from the inittab file, else it will not
be associated with the console and tends to cause many other troubles.
We have a student lab and the A/UX machines get rebooted a lot. Don't
ask me why, I guess students can't read the "Do not reboot" signs. In
any case, we would really like a screen saver that can be run from the
inittab file. Any hints???--
Herb Barad [Signal & Image Processing Laboratory]
[Electrical Engineering Dept. - Tulane Univ.]
INTERNET: barad@ee.tulane.edu
USENET: barad@bourbon.uucp
dlnash@ut-emx.UUCP (Donald L. Nash) (02/19/89)
In article <137@bourbon.ee.tulane.edu>, barad@bourbon.ee.tulane.edu (Herb Barad) writes: > In article <1401@umbio.MIAMI.EDU* aem@Mthvax.Miami.Edu (a.e.mossberg) writes: > *This has been posted before. It is a screen dimmer by Earl Wallace > *at Apple. We use it here on our macs. > > This is a nice dimmer and in fact we use it on our A/UX Macs. > However, it must be run manually from the console once after booting. > It cannot be run automatically from the inittab file, else it will not > be associated with the console and tends to cause many other troubles. I run it from inittab just fine. Just redirect stdout to /dev/console and it works. Here is my line from inittab: dim::once:/usr/local/bin/dimmer -p 0 > /dev/console Don Nash The University of Texas System SMTP: dlnash@emx.utexas.edu Office of Telecommunication Services UUCP: ...!emx!dlnash
wtr@moss.ATT.COM (02/20/89)
In article <10612@ut-emx.UUCP> dlnash@ut-emx.UUCP (Donald L. Nash) writes: >In article <137@bourbon.ee.tulane.edu>, barad@bourbon.ee.tulane.edu (Herb Barad) writes: >> In article <1401@umbio.MIAMI.EDU* aem@Mthvax.Miami.Edu (a.e.mossberg) writes: >> *This has been posted before. It is a screen dimmer by Earl Wallace >> *at Apple. We use it here on our macs. >> >> This is a nice dimmer and in fact we use it on our A/UX Macs. >> However, it must be run manually from the console once after booting. >> It cannot be run automatically from the inittab file, else it will not >> be associated with the console and tends to cause many other troubles. > >I run it from inittab just fine. Just redirect stdout to /dev/console >and it works. Here is my line from inittab: > >dim::once:/usr/local/bin/dimmer -p 0 > /dev/console wouldn't it be a little 'better' to run the dimmer from within the /etc/rc scripts. i'm not real familiar with AU/X, but if it's SysV based, this would be apropriate. just pointing out that it seems to be good practice to keep inittab as clean as possible and remove all the nitty/gritty details down to the script level. ===================================================================== Bill Rankin Bell Labs, Whippany NJ (201) 386-4154 (cornet 232) email address: ...!att!moss!wtr