wmutils

X windows manipulation utilities
git clone git://z3bra.org/wmutils
Log | Files | Refs | LICENSE

commit abfcb8b42aa5f5b4909d573fc9f6c39c1d14ecbf
parent 9fa6cf9b059d4ccf52fea91c044915ec062d2aaf
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec  9 12:36:29 2014

wname: util.c refactoring

Diffstat:
 wname.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/wname.c b/wname.c @@ -3,18 +3,13 @@ #include <xcb/xcb.h> #include <err.h> +#include "util.h" + static xcb_connection_t *conn; static void usage (char *); -static void cleanup (void); static int get_title (xcb_window_t); -static void cleanup (void) -{ - if (conn) - xcb_disconnect(conn); -} - static void usage (char *name) { @@ -54,12 +49,12 @@ int main (int argc, char **argv) if (argc < 2) usage(argv[0]); - atexit(cleanup); - if (xcb_connection_has_error(conn = xcb_connect(NULL, NULL))) - errx(1, "error connecting to X"); + init_xcb(&conn); for (i=1; i < argc; i++) r += get_title(strtoul(argv[i], NULL, 16)); + kill_xcb(&conn); + return r; }