tkillw: kill window instead of client - wmutils - X windows manipulation utilities
(HTM) git clone git://z3bra.org/wmutils
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 977535143f57d53ea186df7f2a94297139a41043
(DIR) parent 7b86e8b8e80cd91e7cd7c4e2b8c8be51db7e1c91
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Tue, 15 Mar 2016 13:24:49 +0100
killw: kill window instead of client
Thanks to @clehner, killw now destroys the given window rather than
killing its parent application. This is the default behavior.
The old behavior (kill the parent) can be obtained with the -p flag.
Diffstat:
M killw.c | 23 +++++++++++++++++++----
M man/killw.1 | 11 +++++++++--
2 files changed, 28 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/killw.c b/killw.c
t@@ -5,6 +5,7 @@
#include <err.h>
#include <xcb/xcb.h>
+#include "arg.h"
#include "util.h"
static xcb_connection_t *conn;
t@@ -14,24 +15,38 @@ static void usage(char *);
static void
usage (char *name)
{
- fprintf(stderr, "usage: %s <wid> [wid...]\n", name);
+ fprintf(stderr, "usage: %s [-p] <wid> [wid...]\n", name);
exit(1);
}
int
main(int argc, char **argv)
{
+ int parent = 0;
+ char *argv0;
+
if (argc < 2)
usage(argv[0]);
+ ARGBEGIN{
+ case 'p': parent=1; break;
+ default: usage(argv0);
+ }ARGEND;
+
init_xcb(&conn);
/* assume remaining arguments are windows */
- while (*argv)
- xcb_kill_client(conn, strtoul(*argv++, NULL, 16));
+ while (*argv) {
+ if (parent) {
+ /* kills the client whose WID belongs to */
+ xcb_kill_client(conn, strtoul(*argv++, NULL, 16));
+ } else {
+ /* destroy the given window and all its children */
+ xcb_destroy_window(conn, strtoul(*argv++, NULL, 16));
+ }
+ }
xcb_flush(conn);
-
kill_xcb(&conn);
return 0;
(DIR) diff --git a/man/killw.1 b/man/killw.1
t@@ -6,11 +6,18 @@
.Nd kill windows
.Sh SYNOPSIS
.Nm killw
+.Op Fl p
.Ar wid Op ...
.Sh DESCRIPTION
.Nm
-kills the window
-.Ar wid .
+will destroy the window passed as an argument, and all its children.
+.Sh OPTIONS
+.Bl -tag -width Ds
+.It Fl p
+Kill the parent application of the window instead of the window itself.
+This is useful to terminate frozen applications (This will close all the windows
+belonging to the applications).
+.El
.Sh ENVIRONMENT
.Nm
acts on the X display specified by the