2 * Prints window's ClassHint
3 * Copyright 2005,2006 by Michal Nazarewicz <mina86@mina86.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * This is part of Tiny Applications Collection
19 * -> http://tinyapps.sourceforge.net/
24 * <CC> -O2 $CFLAGS -I<X11_INC_DIR> -L<X11_LIB_DIR> -lX11 \
25 * -o xgetclass xgetclass.c
27 * <CC> - C Compiler (eg. gcc)
28 * <X11_INC_DIR> - Path to X11's header files (eg. /usr/X11R6/include)
29 * <X11_LIB_DIR> - Path to X11's libraries (eg. /usr/X11R6/lib)
33 * Invocation: xgetclass <wnd-id>
34 * Result: Prints aplication name and class (in separate lines) of
35 * window with ID given as an argument.
42 #include <X11/Xutil.h>
45 int main(int argc
, char **argv
) {
51 /* Get executable name */
52 for (c
= *argv
; *c
; ++c
) {
53 if (*c
=='/' && c
[1]) {
58 /* Invalid number of arguments */
60 fprintf(stderr
, "usage: %s <wnd-id>\n", *argv
);
65 wnd
= strtoul(argv
[1], &c
, 0);
67 fprintf(stderr
, "usage: %s <wnd-id>\n", *argv
);
73 if (!(display
= XOpenDisplay(c
))) {
74 fprintf(stderr
, "%s: can't open display %s\n", *argv
, c
);
79 XGetClassHint(display
, wnd
, &class);
82 printf("%s\n%s\n", class.res_name
, class.res_class
);
83 XFree(class.res_name
);
84 XFree(class.res_class
);