Created
July 13, 2012 11:16
-
-
Save xlab/3104348 to your computer and use it in GitHub Desktop.
Matchbox Keyboard Toggler
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
/* | |
A very simple program to send the toggle-keyboard event to matchbox-keyboard | |
Requires a version of matchbox-keyboard running in daemon mode (-d), and | |
must be a version of matchbox-keyboard that supports the toggle event. | |
Currently the SVN version meets this requirement. | |
Compiling: | |
gcc matchbox-keyboard-toggler.c -o matchbox-keyboard-toggler -lX11 | |
Usage: | |
Just run the program, and it will send the toggle event. | |
*/ | |
#include <X11/Xlib.h> | |
#include <string.h> | |
int main(){ | |
Display *dsp = XOpenDisplay(NULL); | |
if(dsp == NULL){ | |
return 1; | |
} | |
XEvent event; | |
memset (&event, 0, sizeof (XEvent)); | |
Atom Atom_MB_IM_INVOKER_COMMAND = XInternAtom(dsp, | |
"_MB_IM_INVOKER_COMMAND", False); | |
event.xclient.type = ClientMessage; | |
event.xclient.window = DefaultRootWindow(dsp); | |
event.xclient.message_type = Atom_MB_IM_INVOKER_COMMAND; | |
event.xclient.format = 32; | |
event.xclient.data.l[0] = 3; | |
XSendEvent (dsp, | |
DefaultRootWindow(dsp), | |
False, | |
SubstructureRedirectMask | SubstructureNotifyMask, | |
&event); | |
XSync (dsp, False); | |
XCloseDisplay( dsp ); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment