3 * $Id: xtell.c,v 1.5 1999/08/20 07:29:19 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.5 1999/08/20 07:29:19 mdw
33 * New command line syntax, and new atom protocol.
35 * Revision 1.4 1998/12/11 09:50:06 mdw
36 * Minor modifications to work with mLib and mgLib.
38 * Revision 1.3 1998/11/30 22:36:51 mdw
39 * Tidy up tabbing in help texts very slightly.
41 * Revision 1.2 1998/11/21 22:30:25 mdw
42 * Support GNU-style long options throughout, and introduce proper help
43 * text to all programs. Update manual pages to match.
45 * Revision 1.1 1998/11/16 23:00:49 mdw
50 /*----- Header files ------------------------------------------------------*/
57 #include <X11/Xutil.h>
59 #include <mLib/mdwopt.h>
60 #include <mLib/quis.h>
61 #include <mLib/report.h>
66 /*----- Main code ---------------------------------------------------------*/
68 static void version(FILE *fp
)
70 fprintf(fp
, "%s (xtoys version " VERSION
")\n", QUIS
);
73 static void usage(FILE *fp
)
75 fprintf(fp
, "Usage: %s [-d DISPLAY] [ATOM:MSG]\n", QUIS
);
78 int main(int argc
, char *argv
[])
83 char *atom
= XWAIT_DIE
;
84 char *msg
= XWAIT_DIE_MSG
;
86 /* --- Parse options --- */
91 static struct option opt
[] = {
92 { "help", 0, 0, 'h' },
93 { "usage", 0, 0, 'u' },
94 { "version", 0, 0, 'v' },
95 { "display", OPTF_ARGREQ
, 0, 'd' },
96 { "atom", OPTF_ARGREQ
, 0, 'a' },
97 { "msg", OPTF_ARGREQ
, 0, 'm' },
101 int i
= mdwopt(argc
, argv
, "d:a:m:", opt
, 0, 0, 0);
111 "Signals a waiting `xwait' process. Specifically, writes a property\n"
112 "named ATOM to the X root window, with value MSG.\n"
116 "-h, --help Display this help text\n"
117 "-u, --usage Display a short usage summary\n"
118 "-v, --version Display the program's version number\n"
120 "-d, --display=DISPLAY Choose X display to connect to\n"
121 "-a, --atom=ATOM\t Choose property name to set [deprecated]\n"
122 "-m, --msg=MSG Choose value of property to set [deprecated]\n",
153 if ((atom
= strtok(argv
[optind
++], ":")) == 0)
154 die(EXIT_FAILURE
, "missing atom name");
155 if ((p
= strtok(0, ",")) != 0)
164 /* --- Set the property value and exit --- */
166 if ((dpy
= XOpenDisplay(display
)) == 0)
167 die(EXIT_FAILURE
, "couldn't open display");
169 a
= XInternAtom(dpy
, atom
, False
);
170 m
= XInternAtom(dpy
, msg
, False
);
171 xatom_set(dpy
, DefaultRootWindow(dpy
), a
, m
);
177 /*----- That's all, folks -------------------------------------------------*/