3 * $Id: xtell.c,v 1.3 1998/11/30 22:36:51 mdw Exp $
5 * Wake up a waiting xwait process
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.3 1998/11/30 22:36:51 mdw
33 * Tidy up tabbing in help texts very slightly.
35 * Revision 1.2 1998/11/21 22:30:25 mdw
36 * Support GNU-style long options throughout, and introduce proper help
37 * text to all programs. Update manual pages to match.
39 * Revision 1.1 1998/11/16 23:00:49 mdw
44 /*----- Header files ------------------------------------------------------*/
51 #include <X11/Xutil.h>
57 /*----- Main code ---------------------------------------------------------*/
59 static void version(FILE *fp
)
61 fprintf(fp
, "%s (xtoys version " VERSION
")\n", QUIS
);
64 static void usage(FILE *fp
)
66 fprintf(fp
, "Usage: %s [-d DISPLAY] [-a ATOM] [-m MSG]\n", QUIS
);
69 int main(int argc
, char *argv
[])
74 char *atom
= XWAIT_DIE
;
75 char *msg
= XWAIT_DIE_MSG
;
77 /* --- Parse options --- */
82 static struct option opt
[] = {
83 { "help", 0, 0, 'h' },
84 { "usage", 0, 0, 'u' },
85 { "version", 0, 0, 'v' },
86 { "display", required_argument
, 0, 'd' },
87 { "atom", required_argument
, 0, 'a' },
88 { "msg", required_argument
, 0, 'm' },
92 int i
= getopt_long(argc
, argv
, "d:a:m:", opt
, 0);
102 "Signals a waiting `xwait' process. Specifically, writes a property\n"
103 "named ATOM to the X root window, with value MSG.\n"
107 "-h, --help Display this help text\n"
108 "-u, --usage Display a short usage summary\n"
109 "-v, --version Display the program's version number\n"
111 "-d, --display=DISPLAY Choose X display to connect to\n"
112 "-a, --atom=ATOM\t Choose property name to set\n"
113 "-m, --msg=MSG Choose value of property to set\n",
136 fprintf(stderr
, "Usage: xtell [-d DISPLAY] [-a ATOM] [-m MSG]\n");
142 /* --- Connect to the display --- */
144 dpy
= XOpenDisplay(display
);
146 fprintf(stderr
, "xtell: couldn't open display\n");
150 /* --- Find the right atom --- */
152 xwait_die
= XInternAtom(dpy
, atom
, False
);
154 /* --- Set the property value --- */
158 if (!XGetTextProperty(dpy
, DefaultRootWindow(dpy
), &prop
, xwait_die
)) {
159 fprintf(stderr
, "xtell: no xwait listening for `%s'\n", atom
);
162 XStringListToTextProperty(&msg
, 1, &prop
);
163 XSetTextProperty(dpy
, DefaultRootWindow(dpy
), &prop
, xwait_die
);
172 /*----- That's all, folks -------------------------------------------------*/