summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--config.def.h1
-rw-r--r--slstatus.c25
3 files changed, 27 insertions, 0 deletions
diff --git a/README.md b/README.md
index 93b7b12..a67a29d 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ The following information is included:
- 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)
diff --git a/config.def.h b/config.def.h
index caddd7f..1476c30 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,7 @@
- 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]
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);
@@ -323,6 +324,30 @@ kernel_release(void)
}
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)
{
double avgs[3];