Created
May 9, 2018 01:05
-
-
Save fluffy-critter/72f0ba688dec9b2fbef69ba98e318a88 to your computer and use it in GitHub Desktop.
A simple program you can use to move the mouse in X11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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