Added keyboard_indicators (Fixes #31)

This commit is contained in:
Aaron Marcher 2017-01-16 12:10:56 +01:00
parent 3f976aabc0
commit 823f2d047f
No known key found for this signature in database
GPG key ID: 74B048E5C2474F9A
3 changed files with 27 additions and 0 deletions

View file

@ -18,6 +18,7 @@ The following information is included:
- Hostname - Hostname
- IP addresses - IP addresses
- Kernel version - Kernel version
- Keyboard indicators
- Load averages - Load averages
- Memory status (free memory, percentage, total memory and used memory) - Memory status (free memory, percentage, total memory and used memory)
- Swap status (free swap, percentage, total swap and used swap) - Swap status (free swap, percentage, total swap and used swap)

View file

@ -20,6 +20,7 @@
- hostname [argument: NULL] - hostname [argument: NULL]
- ip (ip address) [argument: interface] - ip (ip address) [argument: interface]
- kernel_release (uname -r) [argument: NULL] - kernel_release (uname -r) [argument: NULL]
- keyboard_indicators (caps/num lock indicators) [agrument: NULL]
- load_avg (load average) [argument: NULL] - load_avg (load average) [argument: NULL]
- ram_free (free ram in GB) [argument: NULL] - ram_free (free ram in GB) [argument: NULL]
- ram_perc (ram usage in percent) [argument: NULL] - ram_perc (ram usage in percent) [argument: NULL]

View file

@ -47,6 +47,7 @@ static char *gid(void);
static char *hostname(void); static char *hostname(void);
static char *ip(const char *iface); static char *ip(const char *iface);
static char *kernel_release(void); static char *kernel_release(void);
static char *keyboard_indicators(void);
static char *load_avg(void); static char *load_avg(void);
static char *ram_free(void); static char *ram_free(void);
static char *ram_perc(void); static char *ram_perc(void);
@ -322,6 +323,30 @@ kernel_release(void)
return smprintf("%s", udata.release); 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 * static char *
load_avg(void) load_avg(void)
{ {