X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/7246dc4381c6c95454672a5c1aff65a02d6d3747..1fc5cf00166a5dfefa89c3d6abbe92fedaf71e27:/components/keyboard_indicators.c diff --git a/components/keyboard_indicators.c b/components/keyboard_indicators.c index b7713b6..2f831c8 100644 --- a/components/keyboard_indicators.c +++ b/components/keyboard_indicators.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include +#include #include #include "../util.h" @@ -7,24 +7,24 @@ const char * keyboard_indicators(void) { - Display *dpy = XOpenDisplay(NULL); + Display *dpy; XKeyboardState state; - if (dpy == NULL) { - warnx("XOpenDisplay failed"); + if (!(dpy = XOpenDisplay(NULL))) { + fprintf(stderr, "Cannot open display\n"); 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 ""; + case 1: + return "c"; + case 2: + return "n"; + case 3: + return "cn"; + default: + return ""; } }