Add "uname -r" functionality
authorMike Coddington <mike@coddington.us>
Thu, 3 Nov 2016 16:49:09 +0000 (11:49 -0500)
committerMike Coddington <mike@coddington.us>
Wed, 16 Nov 2016 19:03:15 +0000 (13:03 -0600)
CONTRIBUTORS.md
README.md
config.def.h
slstatus.c

index 7a6184759f50e682619265ce33b1c61f4e646326..3ece0d9fe1d8759c3368eb22f2451985ef4d04d1 100644 (file)
@@ -8,3 +8,4 @@ Thanks you very much for your great help!
 - [sahne](https://github.com/sahne)
 - [Ali H. Fardan](http://raiz.duckdns.org)
 - [Quentin Rameau](https://fifth.space)
+- [Mike Coddington](https://coddington.us)
index d2de5823317ddb22a646c622e44d2a6770763dc0..23e6921337f3db8379ba2f199d651fc93a1802d7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ The following information is included:
 - Username/GID/UID
 - Hostname
 - IP addresses
+- Kernel version
 - Load averages
 - Memory status (free memory, percentage, total memory and used memory)
 - Swap status (free swap, percentage, total swap and used swap)
index bc2835c58c6a8f4f34b0f7be292e4bd4109ab6f2..47e05f06e9405f5ac20e6f59cf4a067cc32a118e 100644 (file)
@@ -19,6 +19,7 @@
 - gid (gid of current user) [argument: NULL]
 - hostname [argument: NULL]
 - ip (ip address) [argument: interface]
+- kernel_release (uname -r) [argument: NULL]
 - load_avg (load average) [argument: NULL]
 - ram_free (free ram in GB) [argument: NULL]
 - ram_perc (ram usage in percent) [argument: NULL]
index 95592261a88c8ba7b71bca83e5d46ef368bf3b84..2b63be452a11742a08077cfce0de1eaedfa18274 100644 (file)
@@ -20,6 +20,7 @@
 #include <sys/socket.h>
 #include <sys/sysinfo.h>
 #include <sys/types.h>
+#include <sys/utsname.h>
 #include <time.h>
 #include <unistd.h>
 #include <X11/Xlib.h>
@@ -68,6 +69,7 @@ static char *username(void);
 static char *vol_perc(const char *card);
 static char *wifi_perc(const char *iface);
 static char *wifi_essid(const char *iface);
+static char *kernel_release(void);
 static void set_status(const char *str);
 static void sighandler(const int signo);
 static void usage(void);
@@ -721,6 +723,16 @@ wifi_essid(const char *iface)
                return smprintf("%s", (char *)wreq.u.essid.pointer);
 }
 
+static char *
+kernel_release(void)
+{
+       struct utsname udata;
+       if (uname(&udata) < 0)
+               return smprintf(UNKNOWN_STR);
+
+       return smprintf("%s", udata.release);
+}
+
 static void
 set_status(const char *str)
 {