Xinqi Bao's Git

wifi: Fix order and add missing header
[slstatus.git] / components / keyboard_indicators.c
1 /* See LICENSE file for copyright and license details. */
2 #include <stdio.h>
3 #include <X11/Xlib.h>
4
5 #include "../util.h"
6
7 const char *
8 keyboard_indicators(void)
9 {
10 Display *dpy;
11 XKeyboardState state;
12
13 if (!(dpy = XOpenDisplay(NULL))) {
14 fprintf(stderr, "Cannot open display\n");
15 return NULL;
16 }
17 XGetKeyboardControl(dpy, &state);
18 XCloseDisplay(dpy);
19
20 switch (state.led_mask) {
21 case 1:
22 return "c";
23 case 2:
24 return "n";
25 case 3:
26 return "cn";
27 default:
28 return "";
29 }
30 }