Created
January 4, 2011 17:59
-
-
Save sergeykish/765118 to your computer and use it in GitHub Desktop.
Xorg get current layout
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
#include <stdio.h> | |
#include <X11/XKBlib.h> | |
int | |
main() | |
{ | |
char* displayName = ""; | |
int eventCode; | |
int errorReturn; | |
int major = XkbMajorVersion; | |
int minor = XkbMinorVersion;; | |
int reasonReturn; | |
Display* display = XkbOpenDisplay(displayName, &eventCode, &errorReturn, &major, &minor, &reasonReturn); | |
if (reasonReturn != XkbOD_Success) | |
return 1; | |
XkbStateRec xkbState; | |
XkbGetState(display, XkbUseCoreKbd, &xkbState); | |
printf("%d\n", xkbState.group); | |
XkbDescRec* kbdDescPtr = XkbAllocKeyboard(); | |
if (kbdDescPtr == NULL) | |
return 1; | |
XkbGetNames(display, XkbSymbolsNameMask, kbdDescPtr); | |
Atom symNameAtom = kbdDescPtr->names->symbols; | |
if (symNameAtom != None) { | |
char* symNameC = XGetAtomName(display, symNameAtom); | |
printf("%s\n", symNameC); | |
XFree(symNameC); | |
} | |
XCloseDisplay(display); | |
return 0; | |
} |
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
$ setxkbmap -print | |
xkb_keymap { | |
xkb_keycodes { include "evdev+aliases(qwerty)" }; | |
xkb_types { include "complete" }; | |
xkb_compat { include "complete" }; | |
xkb_symbols { include "pc+us(dvorak-de)+ru(winkeys-ua):2+inet(evdev)+capslock(grouplock)" }; | |
xkb_geometry { include "pc(pc104)" }; | |
}; | |
$ setxkbmap -print | |
xkb_keymap { | |
xkb_keycodes { include "evdev+aliases(qwerty)" }; | |
xkb_types { include "complete" }; | |
xkb_compat { include "complete" }; | |
xkb_symbols { include "pc+us+inet(evdev)" }; | |
xkb_geometry { include "pc(pc104)" }; | |
}; | |
$ ./getxkbgroupsymbols | |
1 | |
pc+us(dvorak-de)+ru(winkeys-ua):2+inet(evdev)+capslock(grouplock) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment