How to discover screen depth (sou
Richard Saunders
sunuk!sunfra!jfk!rich at sun.com
Sat Dec 10 08:43:07 AEST 1988
Doug Arnold's program (v7n24) does an open("/dev/fb",) followed by an
ioctl(,FBIOGTYPE,) to get the fbinfo. I use a modified version of a
program called fbres.c that came from Chuq von Rospach which does
pr_open() instead.
I ran the two on a 3/110. displaytype gave:
Sun 2 or 3 monochrome 900 x 1152 x 1 pixels
whereas fbres gave:
1152x900C
Here is the source for fbres and how its output can be used in your .login
file (set your path to get /usr/local/bin/`arch`):
/*
* fbres.c
*
* Prints out the resolution of the fb pixrect in a
* form useful for shell scripts.
*
* Usage: fbres [fb-name]
*/
#include <stdio.h>
#include <pixrect/pixrect_hs.h>
main(argc,argv)
int argc;
char *argv[];
{
Pixrect *fbpr;
char *fbname;
if (argc > 1) fbname = argv[1];
else fbname = "/dev/fb";
if ((fbpr = pr_open(fbname)) == NULL) {
fprintf(stderr, "Couldn't open %s pixrect\n", fbname);
exit(1);
}
printf("%dx%d", fbpr->pr_size.x, fbpr->pr_size.y);
printf((fbpr->pr_depth > 1 ? "C" : "M"));
printf("\n");
}
# if you are on the console (you DON'T want to do this when rlogged in!)
# initialize the inputs from the data in your .defaults file
# uses fbres program to check for screen type. Needs SunOS 3.4.
if (`tty` == /dev/console) then
switch (`fbres`)
case "1152x900M":
setenv DEFAULTS_FILE ~/.defaults.lores
alias st 'exec suntools -pattern ~/icons/rrichter.icon -s ~/.suntools.lores'
breaksw
case "1152x900C":
setenv DEFAULTS_FILE ~/.defaults.lores
alias st 'exec suntools -pattern ~/icons/rrichter.icon -s ~/.suntools.color'
breaksw
case "1600x1280M":
setenv DEFAULTS_FILE ~/.defaults.hires
alias st 'exec suntools -pattern ~/icons/rrichter.icon -s ~/.suntools.hires'
breaksw
endsw
endif
More information about the Comp.sys.sun
mailing list