Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A simple program you can use to move the mouse in X11
/* XMouseKeys.c
* Move the mouse cursor by the specified vector, useful for keyboard
* bindings in pwm and other WMs which don't have this functionality
* contact: fluffy at beesbuzz dot biz
* Released into the public domain
* Compile with:
* gcc -o xmousekeys xmousekeys.c -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXext
#include <stdio.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main(int argc, char *argv[])
Display *bob;
int xoff, yoff;
if (argc != 3)
fprintf (stderr, "Usage: %s xoffset yoffset\n", argv[0]);
return 1;
xoff = atoi(argv[1]);
yoff = atoi(argv[2]);
bob = XOpenDisplay(NULL);
if (!bob)
fprintf (stderr, "Could not open display\n");
return 1;
XWarpPointer(bob, None, None, 0, 0, 0, 0, xoff, yoff);
XSync(bob, 0);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.