3 * $Id: xscsize.c,v 1.1 1998/11/16 23:00:49 mdw Exp $
5 * Return X display size to shell script
7 * (c) 1998 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the Edgeware X tools collection.
14 * X tools is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * X tools is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with X tools; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 1998/11/16 23:00:49 mdw
37 /*----- Header files ------------------------------------------------------*/
46 /*----- Main code ---------------------------------------------------------*/
48 int main(int argc, char *argv[])
50 const char *display = 0;
61 /* --- Parse command line options --- */
64 int i = getopt(argc, argv, "d:bcx");
81 fprintf(stderr, "Usage: xscsize [-bcx] [-d DISPLAY]\n");
87 /* --- Sort out the shell type --- *
89 * If the shell name contains the string `csh' then assume it's a C shell.
90 * Otherwise assume it's Bourne. This seems to work in practice.
94 const char *s = getenv("SHELL");
103 if ((f & f_sh) && (f & f_csh)) {
104 fprintf(stderr, "xscsize: make your mind up about your shell type\n");
108 /* --- Get the important information --- */
111 Display *dpy = XOpenDisplay(display);
114 fprintf(stderr, "xscsize: couldn't open display\n");
117 sc = DefaultScreen(dpy);
118 wd = DisplayWidth(dpy, sc);
119 ht = DisplayHeight(dpy, sc);
123 /* --- Do the output thing --- */
126 printf("XWIDTH=%lu XHEIGHT=%lu", wd, ht);
128 printf("; export XWIDTH XHEIGHT");
132 printf("setenv XWIDTH %lu; setenv XHEIGHT %lu", wd, ht);
134 printf("set XWIDTH=%lu XHEIGHT=%lu", wd, ht);
143 /*----- That's all, folks -------------------------------------------------*/