Path: utzoo!utgpu!tmsoft!dptcdc!dpmizar!swrinde!cs.utexas.edu!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: sunuk!sunfra!jfk!rich@sun.com (Richard Saunders) Newsgroups: comp.sys.sun Subject: Re: How to discover screen depth (sou Message-ID: <8811251922.AA11320@jfk.France.Sun.COM> Date: 9 Dec 88 22:43:07 GMT Sender: usenet@rice.edu Organization: Rice University, Houston, Texas Lines: 66 Approved: Sun-Spots@rice.edu Original-Date: Fri, 25 Nov 88 20:22:36 +0100 X-Sun-Spots-Digest: Volume 7, Issue 40, message 7 of 8 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 #include 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