aboutsummaryrefslogtreecommitdiff
path: root/segments/xkb_layout.c
diff options
context:
space:
mode:
authorCody Hiar <codyfh@gmail.com>2017-04-20 19:37:10 -0600
committerCody Hiar <codyfh@gmail.com>2017-04-20 19:37:10 -0600
commit2dd809781527976307b47a598887062047e202c9 (patch)
tree8b29daba2c1ef072f380ef530b7e7d9256e43eb3 /segments/xkb_layout.c
parentbaeb698bb006193559fc5aa1901180a3ccc73b7a (diff)
Making tmux configuration much easier to manage
Diffstat (limited to 'segments/xkb_layout.c')
-rw-r--r--segments/xkb_layout.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/segments/xkb_layout.c b/segments/xkb_layout.c
deleted file mode 100644
index 7c94f96..0000000
--- a/segments/xkb_layout.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* xkb_layout
- * Description:
- * This program will connect to the X Server and print the id of the currently
- * active keyboard layout.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <X11/XKBlib.h>
-
-#ifdef DEBUG
- #define DO_DEBUG DEBUG
-#else
- #define DO_DEBUG 0
-#endif
-#define DEBUG_PRINTF(...) do{ if (DO_DEBUG) { printf(__VA_ARGS__);} } while(0)
-
-int main() {
- // Get X display
- char *displayName = "";
- int eventCode;
- int errorReturn;
- int major = XkbMajorVersion;
- int minor = XkbMinorVersion;;
- int reasonReturn;
- Display *_display = XkbOpenDisplay(displayName, &eventCode, &errorReturn,
- &major, &minor, &reasonReturn);
- bool error = false;
- switch (reasonReturn) {
- case XkbOD_BadLibraryVersion:
- DEBUG_PRINTF("Bad XKB library version.\n");
- error = true;
- break;
- case XkbOD_ConnectionRefused:
- DEBUG_PRINTF("Connection to X server refused.\n");
- error = true;
- break;
- case XkbOD_BadServerVersion:
- DEBUG_PRINTF("Bad X11 server version.\n");
- error = true;
- break;
- case XkbOD_NonXkbServer:
- DEBUG_PRINTF("XKB not present.\n");
- error = true;
- break;
- case XkbOD_Success:
- break;
- }
-
- if (error) {
- return EXIT_FAILURE;
- }
-
- // Get current state of keyboard.
- int _deviceId = XkbUseCoreKbd;
- XkbStateRec xkbState;
- XkbGetState(_display, _deviceId, &xkbState);
- // print the groupnumber, may be used with setxkbmap -query to get name
- // of current layout
- printf("%d\n", xkbState.group);
- return 0;
- return EXIT_SUCCESS;
-}