Skip to content

Instantly share code, notes, and snippets.

@xlab
Created July 13, 2012 11:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xlab/3104348 to your computer and use it in GitHub Desktop.
Save xlab/3104348 to your computer and use it in GitHub Desktop.
Matchbox Keyboard Toggler
/*
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