From c3eb0c401200320151770680b9291197e759bfc9 Mon Sep 17 00:00:00 2001 From: Mike Coddington Date: Thu, 3 Nov 2016 11:49:09 -0500 Subject: [PATCH] Add "uname -r" functionality --- CONTRIBUTORS.md | 1 + README.md | 1 + config.def.h | 1 + slstatus.c | 12 ++++++++++++ 4 files changed, 15 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7a61847..3ece0d9 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -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) diff --git a/README.md b/README.md index d2de582..23e6921 100644 --- 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) diff --git a/config.def.h b/config.def.h index bc2835c..47e05f0 100644 --- a/config.def.h +++ b/config.def.h @@ -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] diff --git a/slstatus.c b/slstatus.c index 9559226..2b63be4 100644 --- a/slstatus.c +++ b/slstatus.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -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) {