tkillw.c - wmutils - X windows manipulation utilities
(HTM) git clone git://z3bra.org/wmutils
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
tkillw.c (920B)
---
1 /* See LICENSE file for copyright and license details. */
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <err.h>
6 #include <xcb/xcb.h>
7 #include <xcb/xcb_aux.h>
8
9 #include "arg.h"
10 #include "util.h"
11
12 static xcb_connection_t *conn;
13
14 static void usage(char *);
15
16 static void
17 usage (char *name)
18 {
19 fprintf(stderr, "usage: %s [-p] <wid> [wid...]\n", name);
20 exit(1);
21 }
22
23 int
24 main(int argc, char **argv)
25 {
26 int parent = 0;
27 char *argv0;
28
29 if (argc < 2)
30 usage(argv[0]);
31
32 ARGBEGIN{
33 case 'p': parent=1; break;
34 default: usage(argv0);
35 }ARGEND;
36
37 init_xcb(&conn);
38
39 /* assume remaining arguments are windows */
40 while (*argv) {
41 if (parent) {
42 /* kills the client whose WID belongs to */
43 xcb_kill_client(conn, strtoul(*argv++, NULL, 16));
44 } else {
45 /* destroy the given window and all its children */
46 xcb_destroy_window(conn, strtoul(*argv++, NULL, 16));
47 }
48 }
49
50 xcb_aux_sync(conn);
51 kill_xcb(&conn);
52
53 return 0;
54 }