From 85a2b9b79d1f5422bee87ef9ca0cd33a02440c1c Mon Sep 17 00:00:00 2001 From: Aaron Marcher Date: Thu, 18 Aug 2016 13:43:18 +0200 Subject: added uptime function --- slstatus.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'slstatus.c') diff --git a/slstatus.c b/slstatus.c index 87e705d..fee56fc 100644 --- a/slstatus.c +++ b/slstatus.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -521,6 +522,23 @@ temp(const char *file) return smprintf("%d°C", temperature / 1000); } +/* uptime */ +char * +uptime(const char *null) +{ + struct sysinfo info; + int hours = 0; + int minutes = 0; + + /* get info */ + sysinfo(&info); + hours = info.uptime / 3600; + minutes = (info.uptime - hours * 3600 ) / 60; + + /* return it */ + return smprintf("%dh %dm", hours, minutes); +} + /* username */ char * username(const char *null) -- cgit v1.2.3