[wiki] [sites] bar_monitor - Added Uptime Function. || levi0x0

From: <git_AT_suckless.org>
Date: Sat, 19 Jul 2014 14:08:25 +0200

commit 105e8b587a48f7a8294c51e0a08a1485a53295c3
Author: levi0x0 <levi0x0x_AT_gmail.com>
Date: Sat Jul 19 15:08:09 2014 +0300

    bar_monitor - Added Uptime Function.

diff --git a/dwm.suckless.org/dwmstatus/bar_monitor-0.4.c b/dwm.suckless.org/dwmstatus/bar_monitor-0.4.c
index fcf6cdd..faa8c98 100644
--- a/dwm.suckless.org/dwmstatus/bar_monitor-0.4.c
+++ b/dwm.suckless.org/dwmstatus/bar_monitor-0.4.c
_AT_@ -2,7 +2,7 @@
  * bar_monitor.c - another version of dwmstatus.
  *
  * Written by: levi0x0 (levi0x0x_AT_gmail.com) for dwm.
- * Date: 02/07/2014
+ * Date: 19/07/2014, 02/07/2014
  * Version: 0.4
  * License: GPL 3
  *
_AT_@ -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
  *
_AT_@ -33,6 +34,7 @@
 
 
 #include <stdio.h>
+#include <sys/sysinfo.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
_AT_@ -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*/
_AT_@ -88,8 +96,21 @@ int main(int argc, char **argv) {
                 printf("w00t?
");
 
         }
+
+ #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
index 0557e09..dc63358 100644
--- a/dwm.suckless.org/dwmstatus/index.md
+++ b/dwm.suckless.org/dwmstatus/index.md
_AT_@ -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
Received on Sat Jul 19 2014 - 14:08:25 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:39:26 CEST