tnew tool: wmp - wmutils - X windows manipulation utilities
(HTM) git clone git://z3bra.org/wmutils
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit e62fde54308511ff5e2b5a715fd691d071b0545a
(DIR) parent c420551c1091fb6edda67493ea22925050a792ea
(HTM) Author: dcat <dcat@iotek.org>
Date: Thu, 18 Dec 2014 17:06:04 +0100
new tool: wmp
Diffstat:
M Makefile | 3 ++-
M man/Makefile | 3 ++-
A man/wmp.1 | 25 +++++++++++++++++++++++++
A wmp.c | 59 +++++++++++++++++++++++++++++++
4 files changed, 88 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/Makefile b/Makefile
t@@ -14,7 +14,8 @@ SRC = \
wrs.c \
chwb.c \
ignw.c \
- wname.c
+ wname.c \
+ wmp.c
OBJ = $(SRC:.c=.o)
BIN = $(SRC:.c=)
(DIR) diff --git a/man/Makefile b/man/Makefile
t@@ -13,7 +13,8 @@ SRC = \
wrs.1 \
chwb.1 \
ignw.1 \
- wname.1
+ wname.1 \
+ wmp.1
MAN = $(SRC:.1=.1.gz)
(DIR) diff --git a/man/wmp.1 b/man/wmp.1
t@@ -0,0 +1,25 @@
+.Dd December 13, 2014
+.Dt WTP 1
+.Os wmutils
+.Sh NAME
+.Nm wmp
+.Nd warp mouse cursor
+.Sh SYNOPSIS
+.Nm wmp
+.Ar <a | r> <x> <y>
+.Sh DESCRIPTION
+.Nm
+warps cursor to an absolute or relative position, passed by
+.Ar x
+and
+.Ar y ,
+.Sh ENVIRONMENT
+.Nm
+acts on the X display specified by the
+.Ev DISPLAY
+variable.
+.Sh EXAMPLES
+.Pp
+.Dl $ wmp a $(wattr xy `pfw`)
+.Pp
+.Dl $ wmp r -100 0
(DIR) diff --git a/wmp.c b/wmp.c
t@@ -0,0 +1,59 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <xcb/xcb.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <err.h>
+
+#include "util.h"
+
+enum {
+ ABSOLUTE = 0,
+ RELATIVE = 1
+};
+
+static xcb_connection_t *conn;
+static xcb_screen_t *scr;
+
+static void usage (char *);
+static void warp_cursor (int, int, int);
+
+static void
+usage (char *name)
+{
+ fprintf(stderr, "For more details see %s(1)\n", name);
+ exit(1);
+}
+
+static void
+warp_cursor (int x, int y, int mode)
+{
+ xcb_warp_pointer(conn, XCB_NONE, mode ? XCB_NONE : scr->root,
+ 0, 0, 0, 0, x, y);
+}
+
+int
+main (int argc, char **argv)
+{
+ int mode = ABSOLUTE;
+
+ if (argc != 4)
+ usage(argv[0]);
+
+ init_xcb(&conn);
+ get_screen(conn, &scr);
+
+ switch (argv[1][0]) {
+ case 'a': mode = ABSOLUTE;
+ break;
+ case 'r': mode = RELATIVE;
+ break;
+ }
+
+ warp_cursor(atoi(argv[2]), atoi(argv[3]), mode);
+
+ xcb_flush(conn);
+
+ kill_xcb(&conn);
+ return 0;
+}