wmutils

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

commit 6a73d08cd09a1b59c89be0727630f6c20e162da0
parent 0ac45c44cc65f8f5a13bce19af368b07e9862ce1
Author: z3bra <willy@mailoo.org>
Date:   Mon Dec  1 21:11:03 2014

thanks dcat for the lil' trick

Diffstat:
 killw.c |  7 +++----
 lsw.c   |  6 +++---
 mapw.c  |  6 +++---
 wrs.c   | 10 ++++++----
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/killw.c b/killw.c @@ -26,13 +26,12 @@ cleanup(void) int main(int argc, char **argv) { - int i; - atexit(cleanup); xcbinit(); - for (i=1; i<argc; i++) - xcb_kill_client(conn, strtoul(argv[i], NULL, 16)); + /* assume remaining arguments are windows */ + while (*argv) + xcb_kill_client(conn, strtoul(*argv++, NULL, 16)); xcb_flush(conn); diff --git a/lsw.c b/lsw.c @@ -88,7 +88,7 @@ listwindows(xcb_window_t w, int listhidden) int main(int argc, char **argv) { - int i, hiddenflag = 0, rootflag = 0; + int hiddenflag = 0, rootflag = 0; ARGBEGIN { case 'a': hiddenflag = 1; break; @@ -107,8 +107,8 @@ main(int argc, char **argv) if (argc == 0) listwindows(scrn->root, hiddenflag); - for (i=0; i<argc; i++) - listwindows(strtoul(argv[i], NULL, 16), hiddenflag); + while (*argv) + listwindows(strtoul(*argv++, NULL, 16), hiddenflag); return 0; } diff --git a/mapw.c b/mapw.c @@ -63,7 +63,7 @@ ismapped(xcb_window_t w) int main(int argc, char **argv) { - int i, mapflag = 0; + int mapflag = 0; xcb_window_t w = 0; ARGBEGIN { @@ -79,8 +79,8 @@ main(int argc, char **argv) atexit(cleanup); xcbinit(); - for (i=0; i<argc; i++) { - w = strtoul(argv[i], NULL, 16); + while (*argv) { + w = strtoul(*argv++, NULL, 16); switch (mapflag) { case MAP: diff --git a/wrs.c b/wrs.c @@ -83,16 +83,18 @@ resize(xcb_window_t w, int x, int y) int main(int argc, char **argv) { - int i; - + int x, y; if (argc < 4) errx(1, "usage: %s <x> <y> <wid> [wid..]", argv[0]); atexit(cleanup); xcbinit(); - for (i=3; i<argc; i++) - resize(strtoul(argv[i], NULL, 16), atoi(argv[1]), atoi(argv[2])); + x = atoi(*(++argv)); + y = atoi(*(++argv)); + + while (*argv) + resize(strtoul(*argv++, NULL, 16), x, y); xcb_flush(conn);