wmutils

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

commit 3947e719a98cdd4378fd894981a669092800c46f
parent e62fde54308511ff5e2b5a715fd691d071b0545a
Author: z3bra <willy@mailoo.org>
Date:   Thu Dec 18 19:38:25 2014

make wmp uses flags, and print an helpful usage message

Diffstat:
 wmp.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/wmp.c b/wmp.c @@ -5,6 +5,7 @@ #include <stdio.h> #include <err.h> +#include "arg.h" #include "util.h" enum { @@ -21,7 +22,7 @@ static void warp_cursor (int, int, int); static void usage (char *name) { - fprintf(stderr, "For more details see %s(1)\n", name); + fprintf(stderr, "usage: %s -ar <x> <y>\n", name); exit(1); } @@ -35,22 +36,24 @@ warp_cursor (int x, int y, int mode) int main (int argc, char **argv) { + char *argv0; int mode = ABSOLUTE; - if (argc != 4) - usage(argv[0]); - - init_xcb(&conn); - get_screen(conn, &scr); - - switch (argv[1][0]) { + ARGBEGIN { case 'a': mode = ABSOLUTE; break; case 'r': mode = RELATIVE; break; - } + default : usage(argv0); + } ARGEND; + + if (argc != 2) + usage(argv0); + + init_xcb(&conn); + get_screen(conn, &scr); - warp_cursor(atoi(argv[2]), atoi(argv[3]), mode); + warp_cursor(atoi(argv[0]), atoi(argv[1]), mode); xcb_flush(conn);