Skip to content

Instantly share code, notes, and snippets.

@RauliL
Created June 24, 2021 06:51
Show Gist options
  • Save RauliL/c67bb7345d3964aa4b9158ccf1339c53 to your computer and use it in GitHub Desktop.
Save RauliL/c67bb7345d3964aa4b9158ccf1339c53 to your computer and use it in GitHub Desktop.
CLI utility for turning off capslock
/* Kompilera med: cc TURN-OFF-CAPSLOCK.c -lX11 -o TURN-OFF-CAPSLOCK */
#include <stdlib.h>
#include <stdio.h>
#include <X11/X.h>
#include <X11/XKBlib.h>
int main()
{
Display* display;
Bool sent;
int err;
if (!(display = XOpenDisplay(NULL)))
{
fprintf(stderr, "Couldn't open display\n");
exit(EXIT_FAILURE);
}
if (!(sent = XkbLockModifiers(display, XkbUseCoreKbd, LockMask, 0)))
{
fprintf(stderr, "Couldn't send LatchLockState\n");
exit(EXIT_FAILURE);
}
if ((err = XCloseDisplay(display)))
{
fprintf(stderr, "XCloseDisplay returned %d\n", err);
exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment