summaryrefslogtreecommitdiff
path: root/keyboard_indicators.c
blob: 4aeae0dc2fa0d0a1878ea8d0f7cfdcf479077cd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <err.h>
#include <X11/Xlib.h>

#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 "";
	}
}