sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 105e8b587a48f7a8294c51e0a08a1485a53295c3
parent 63ca06da65af0063b7c9e49a191e07d5de9f8ac8
Author: levi0x0 <levi0x0x@gmail.com>
Date:   Sat, 19 Jul 2014 15:08:09 +0300

bar_monitor - Added Uptime Function.

Diffstat:
Mdwm.suckless.org/dwmstatus/bar_monitor-0.4.c | 27++++++++++++++++++++++++---
Mdwm.suckless.org/dwmstatus/index.md | 2+-
2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/dwm.suckless.org/dwmstatus/bar_monitor-0.4.c b/dwm.suckless.org/dwmstatus/bar_monitor-0.4.c @@ -2,7 +2,7 @@ * bar_monitor.c - another version of dwmstatus. * * Written by: levi0x0 (levi0x0x@gmail.com) for dwm. - * Date: 02/07/2014 + * Date: 19/07/2014, 02/07/2014 * Version: 0.4 * License: GPL 3 * @@ -11,6 +11,7 @@ * 2. temerature * 3. wireless Status. * 4. battery status. + * 5. Uptime (Optional) * * if you are not using laptop, please define: LAPTOP 0 * @@ -33,6 +34,7 @@ #include <stdio.h> +#include <sys/sysinfo.h> #include <stdlib.h> #include <string.h> #include <time.h> @@ -49,12 +51,18 @@ #define pcapacity open_capacity() #define temp read_temp() #define nett net() -#define LAPTOP 1 +/* +1 - True +0 - False +*/ +#define LAPTOP 1 +#define DISPLAY_UPTIME 0 static char status_linecp[STR_SIZE]; static char time_buffer[STR_SIZE]; static char net_buffer[STR_SIZE]; +static char uptime[STR_SIZE]; int capacity; /*prototypes*/ @@ -88,8 +96,21 @@ int main(int argc, char **argv) { printf("w00t?\n"); } + + #if DISPLAY_UPTIME + struct sysinfo sys; + int h = 0; + int m = 0; + + sysinfo(&sys); + + h = sys.uptime / 3600; + m = ( sys.uptime - h * 3600) / 60; + printf(" (%dh, %dm)", h, m); + #endif + #if LAPTOP - printf(" %s %dC %s", nett,temp, date); + printf(" %s %dC %s", nett,temp, date); #else printf(" %dC %s", temp, date); #endif diff --git a/dwm.suckless.org/dwmstatus/index.md b/dwm.suckless.org/dwmstatus/index.md @@ -23,7 +23,7 @@ Please add your own version of dwmstatus here. * [profil-dwmstatus-1.0.c](profil-dwmstatus-1.0.c) - cpufreq, battery percent and date/time * [suspend-statusbar.c](suspend-statusbar.c) - loadavg, wifi, battery and date. If battery goes below threshold - run suspend command * [gods](https://github.com/schachmat/gods) - implemented in Go. prints network speed, cpu, ram, date/time -* [barmonitor](bar_monitor-0.4.c) - displays, battery status, date/time, temperature, network status. +* [barmonitor](bar_monitor-0.4.c) - displays, battery status, date/time, temperature, network status, Uptime (Optinal). Helper functions