mirror of
https://github.com/pikami/slstatus.git
synced 2024-11-30 15:25:41 +00:00
ee5ec75621
- Use block for single statement ifs - Keep lines to reasonable length (current debate as to reasonable) - When functions return -1 for error test against 0 not -1 - Do not indent cases another level - Do not test against NULL and 0 explicitly - Use tabs for indentation, use spaces for alignment
31 lines
482 B
C
31 lines
482 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <stdio.h>
|
|
#include <X11/Xlib.h>
|
|
|
|
#include "../util.h"
|
|
|
|
const char *
|
|
keyboard_indicators(void)
|
|
{
|
|
Display *dpy;
|
|
XKeyboardState state;
|
|
|
|
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 "";
|
|
}
|
|
}
|