6ca8a283bfff5ad0eb545713af2cb5edbc05b2b0
3 * $Id: xtell.c,v 1.2 1998/11/21 22:30:25 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.2 1998/11/21 22:30:25 mdw
33 * Support GNU-style long options throughout, and introduce proper help
34 * text to all programs. Update manual pages to match.
36 * Revision 1.1 1998/11/16 23:00:49 mdw
41 /*----- Header files ------------------------------------------------------*/
48 #include <X11/Xutil.h>
54 /*----- Main code ---------------------------------------------------------*/
56 static void version(FILE *fp
)
58 fprintf(fp
, "%s (xtoys version " VERSION
")\n", QUIS
);
61 static void usage(FILE *fp
)
63 fprintf(fp
, "Usage: %s [-d DISPLAY] [-a ATOM] [-m MSG]\n", QUIS
);
66 int main(int argc
, char *argv
[])
71 char *atom
= XWAIT_DIE
;
72 char *msg
= XWAIT_DIE_MSG
;
74 /* --- Parse options --- */
79 static struct option opt
[] = {
80 { "help", 0, 0, 'h' },
81 { "usage", 0, 0, 'u' },
82 { "version", 0, 0, 'v' },
83 { "display", required_argument
, 0, 'd' },
84 { "atom", required_argument
, 0, 'a' },
85 { "msg", required_argument
, 0, 'm' },
89 int i
= getopt_long(argc
, argv
, "d:a:m:", opt
, 0);
99 "Signals a waiting `xwait' process. Specifically, writes a property\n"
100 "named ATOM to the X root window, with value MSG.\n"
104 "-h, --help Display this help text\n"
105 "-u, --usage Display a short usage summary\n"
106 "-v, --version Display the program's version number\n"
108 "-d, --display=DISPLAY Choose X display to connect to\n"
109 "-a, --atom=ATOM Choose property name to set\n"
110 "-m, --msg=MSG Choose value of property to set\n",
133 fprintf(stderr
, "Usage: xtell [-d DISPLAY] [-a ATOM] [-m MSG]\n");
139 /* --- Connect to the display --- */
141 dpy
= XOpenDisplay(display
);
143 fprintf(stderr
, "xtell: couldn't open display\n");
147 /* --- Find the right atom --- */
149 xwait_die
= XInternAtom(dpy
, atom
, False
);
151 /* --- Set the property value --- */
155 if (!XGetTextProperty(dpy
, DefaultRootWindow(dpy
), &prop
, xwait_die
)) {
156 fprintf(stderr
, "xtell: no xwait listening for `%s'\n", atom
);
159 XStringListToTextProperty(&msg
, 1, &prop
);
160 XSetTextProperty(dpy
, DefaultRootWindow(dpy
), &prop
, xwait_die
);
169 /*----- That's all, folks -------------------------------------------------*/