brought back update interval
authorAaron Marcher <info@nulltime.net>
Fri, 9 Sep 2016 17:26:06 +0000 (19:26 +0200)
committerAaron Marcher (drkhsh) <info@nulltime.net>
Fri, 9 Sep 2016 17:26:06 +0000 (19:26 +0200)
TODO.md
config.def.h
slstatus.c

diff --git a/TODO.md b/TODO.md
index ea038b2bcd9d696a04ccf20955329036e89aba7f..14f5ec79a54d81a97863d25877656a08a8056eca 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,3 +2,4 @@ Todo
 ====
 
 - slstatus icon (in that cool dwm icon style)
+- ugly cpu function
index 1fbe253a128613fe437a9d6705e7adc3692a2ab5..b10586912e5347a07b9d12139e1ed9d482a5c850 100644 (file)
@@ -1,15 +1,18 @@
 /* See LICENSE file for copyright and license details. */
 
 /* alsa sound */
-#define ALSA_CHANNEL "Master"
+#define ALSA_CHANNEL    "Master"
 
 /* battery */
-#define BATTERY_PATH "/sys/class/power_supply/"
-#define BATTERY_NOW  "energy_now"
-#define BATTERY_FULL "energy_full_design"
+#define BATTERY_PATH    "/sys/class/power_supply/"
+#define BATTERY_NOW     "energy_now"
+#define BATTERY_FULL    "energy_full_design"
+
+/* how often to update the statusbar (min value == 1) */
+#define UPDATE_INTERVAL 1
 
 /* text to show if no value can be retrieved */
-#define UNKNOWN_STR  "n/a"
+#define UNKNOWN_STR     "n/a"
 
 /* statusbar
 - battery_perc (battery percentage) [argument: battery name]
index 73dc5a3a74fd436b339b0473a3a1f2fee4db52a0..6c25f3f6eb98da97f7b45ef1977258dd5c2bbdd0 100644 (file)
@@ -126,7 +126,7 @@ battery_perc(const char *battery)
 
 static char *
 cpu_perc(void)
-{
+{ /* FIXME: ugly function, would be better without sleep(), see below */
        int perc;
        long double a[4], b[4];
        FILE *fp = fopen("/proc/stat","r");
@@ -601,7 +601,9 @@ main(void)
                }
                XStoreName(dpy, DefaultRootWindow(dpy), status_string);
                XSync(dpy, False);
+               sleep(UPDATE_INTERVAL - 1); /* FIXME: ugly cpu function which uses 1 second */
        }
+
        XCloseDisplay(dpy);
 
        return 0;