From 823f2d047f9f14c5e401c337274c8c19542b3065 Mon Sep 17 00:00:00 2001 From: Aaron Marcher Date: Mon, 16 Jan 2017 12:10:56 +0100 Subject: Added keyboard_indicators (Fixes #31) --- slstatus.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'slstatus.c') diff --git a/slstatus.c b/slstatus.c index 89186d6..d29436d 100644 --- a/slstatus.c +++ b/slstatus.c @@ -47,6 +47,7 @@ static char *gid(void); static char *hostname(void); static char *ip(const char *iface); static char *kernel_release(void); +static char *keyboard_indicators(void); static char *load_avg(void); static char *ram_free(void); static char *ram_perc(void); @@ -322,6 +323,30 @@ kernel_release(void) return smprintf("%s", udata.release); } +static char * +keyboard_indicators(void) +{ + Display *dpy = XOpenDisplay(NULL); + XKeyboardState state; + XGetKeyboardControl(dpy, &state); + + switch (state.led_mask) { + case 1: + return smprintf("c"); + break; + case 2: + return smprintf("n"); + break; + case 3: + return smprintf("cn"); + break; + default: + return smprintf(""); + } + + XCloseDisplay(dpy); +} + static char * load_avg(void) { -- cgit v1.2.3