From 6820631175868c277effa7cc05f9cb3197b72654 Mon Sep 17 00:00:00 2001 From: Aaron Marcher Date: Sun, 17 Sep 2017 16:18:17 +0200 Subject: Split into multiple files For multiple reasons the program is now split: - Make future porting to OpenBSD easier - Assign header includes to individiual functions - Make future program extensions easier - Recompile only changed parts --- keyboard_indicators.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 keyboard_indicators.c (limited to 'keyboard_indicators.c') diff --git a/keyboard_indicators.c b/keyboard_indicators.c new file mode 100644 index 0000000..4aeae0d --- /dev/null +++ b/keyboard_indicators.c @@ -0,0 +1,29 @@ +#include +#include + +#include "util.h" + +const char * +keyboard_indicators(void) +{ + Display *dpy = XOpenDisplay(NULL); + XKeyboardState state; + + if (dpy == NULL) { + warnx("XOpenDisplay failed"); + return NULL; + } + XGetKeyboardControl(dpy, &state); + XCloseDisplay(dpy); + + switch (state.led_mask) { + case 1: + return "c"; + case 2: + return "n"; + case 3: + return "cn"; + default: + return ""; + } +} -- cgit v1.2.3