all repos — slstatus @ 823f2d047f9f14c5e401c337274c8c19542b3065

my build of slstatus (tools.suckless.org/slstatus/)

Added keyboard_indicators (Fixes #31)
Aaron Marcher info@nulltime.net
Mon, 16 Jan 2017 12:10:56 +0100
commit

823f2d047f9f14c5e401c337274c8c19542b3065

parent

3f976aabc08dd7d4762b0e04f0cbe8550f0e3ced

3 files changed, 27 insertions(+), 0 deletions(-)

jump to
M README.mdREADME.md

@@ -18,6 +18,7 @@ - Username/GID/UID

- Hostname - IP addresses - Kernel version +- Keyboard indicators - Load averages - Memory status (free memory, percentage, total memory and used memory) - Swap status (free swap, percentage, total swap and used swap)
M config.def.hconfig.def.h

@@ -20,6 +20,7 @@ - gid (gid of current user) [argument: NULL]

- hostname [argument: NULL] - ip (ip address) [argument: interface] - kernel_release (uname -r) [argument: NULL] +- keyboard_indicators (caps/num lock indicators) [agrument: NULL] - load_avg (load average) [argument: NULL] - ram_free (free ram in GB) [argument: NULL] - ram_perc (ram usage in percent) [argument: NULL]
M slstatus.cslstatus.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);

@@ -320,6 +321,30 @@ return smprintf(UNKNOWN_STR);

} 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 *