keyboard_indicators: fix segfault when -s is specified

This commit is contained in:
Ali H. Fardan authored and Aaron Marcher committed 2017-08-12 12:50:11 +02:00
1 parent 6f01174392
commit 2c114ec2b5
1 file changed
+6
+6
View File
@@ -380,9 +380,15 @@ kernel_release(void)
static const char *
keyboard_indicators(void)
{
Display *dpy = XOpenDisplay(NULL);
XKeyboardState state;
if (dpy == NULL) {
warnx("XOpenDisplay failed");
return UNKNOWN_STR;
}
XGetKeyboardControl(dpy, &state);
XCloseDisplay(dpy);
switch (state.led_mask) {
case 1: