/* * gcc -Wall -o CapsLockToggle CapsLockToggle.c -L/usr/X11R6/lib -lX11 -lXtst */ #include #include #include #include #include #include int main (void) { char *display_name; Display *d; display_name=getenv("DISPLAY"); d = XOpenDisplay(display_name); if (d == NULL) { printf("Unable to open Display: %s\n", display_name); exit(1); } XTestFakeKeyEvent( d, XKeysymToKeycode( d, XK_Caps_Lock ), True, CurrentTime ); XTestFakeKeyEvent( d, XKeysymToKeycode( d, XK_Caps_Lock ), False, CurrentTime ); XCloseDisplay(d); return 0; }