added uptime function
This commit is contained in:
parent
83c98554ed
commit
85a2b9b79d
4 changed files with 21 additions and 0 deletions
|
@ -20,6 +20,7 @@ The following information is included:
|
||||||
- load avg
|
- load avg
|
||||||
- ram numbers (free ram, percentage, total ram and used ram)
|
- ram numbers (free ram, percentage, total ram and used ram)
|
||||||
- temperature
|
- temperature
|
||||||
|
- uptime
|
||||||
- volume percentage (alsa)
|
- volume percentage (alsa)
|
||||||
- wifi percentage and essid
|
- wifi percentage and essid
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ static const char unknowntext[] = "n/a";
|
||||||
- run_command (run custom shell command) [argument: command]
|
- run_command (run custom shell command) [argument: command]
|
||||||
- temp (temperature in degrees) [argument: temperature file]
|
- temp (temperature in degrees) [argument: temperature file]
|
||||||
- uid (uid of current user) [argument: NULL]
|
- uid (uid of current user) [argument: NULL]
|
||||||
|
- uptime (uptime) [argument: NULL]
|
||||||
- username (username of current user) [argument: NULL]
|
- username (username of current user) [argument: NULL]
|
||||||
- vol_perc (alsa volume and mute status in percent) [argument: soundcard]
|
- vol_perc (alsa volume and mute status in percent) [argument: soundcard]
|
||||||
- wifi_perc (wifi signal in percent) [argument: wifi card interface name]
|
- wifi_perc (wifi signal in percent) [argument: wifi card interface name]
|
||||||
|
|
18
slstatus.c
18
slstatus.c
|
@ -18,6 +18,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -521,6 +522,23 @@ temp(const char *file)
|
||||||
return smprintf("%d°C", temperature / 1000);
|
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 */
|
/* username */
|
||||||
char *
|
char *
|
||||||
username(const char *null)
|
username(const char *null)
|
||||||
|
|
|
@ -33,6 +33,7 @@ char *ram_total(const char *);
|
||||||
char *run_command(const char *);
|
char *run_command(const char *);
|
||||||
char *temp(const char *);
|
char *temp(const char *);
|
||||||
char *uid(const char*);
|
char *uid(const char*);
|
||||||
|
char *uptime(const char*);
|
||||||
char *username(const char*);
|
char *username(const char*);
|
||||||
char *vol_perc(const char *);
|
char *vol_perc(const char *);
|
||||||
char *wifi_perc(const char *);
|
char *wifi_perc(const char *);
|
||||||
|
|
Loading…
Reference in a new issue