]> git.sur5r.net Git - i3/i3status/commitdiff
Make runwatches work again
authorMichael Stapelberg <michael+x200@stapelberg.de>
Tue, 7 Oct 2008 09:54:04 +0000 (11:54 +0200)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Tue, 7 Oct 2008 09:54:04 +0000 (11:54 +0200)
config.h
wmiistatus.c
wmiistatus.h

index 8b4f01e8205f7ace9e3fa16a85831bdb780900c6..fa2f5d5a2238c9c915903a3586579789a94ec1e0 100644 (file)
--- a/config.h
+++ b/config.h
@@ -7,8 +7,11 @@ const char *battery = "/sys/class/power_supply/BAT0/uevent";
 const char *run_watches[] = {"DHCP", "/var/run/dhclient.pid",
                             "VPN", "/var/run/vpnc*.pid"};
 
-#define ORDER_WLAN     "0"
-#define ORDER_ETH      "1"
-#define ORDER_BATTERY  "2"
-#define ORDER_LOAD     "3"
-#define ORDER_TIME     "4"
+#define ORDER_RUN      "0"
+#define ORDER_WLAN     "1"
+#define ORDER_ETH      "2"
+#define ORDER_BATTERY  "3"
+#define ORDER_LOAD     "4"
+#define ORDER_TIME     "5"
+
+#define USE_COLORS
index c26781abe0c6e536d7ab8770025d076d67888e67..c47b5289e05c6b247e52cdb47e858b2790571f2e 100644 (file)
@@ -124,14 +124,6 @@ static char *skip_character(char *input, char character, int amount) {
        return (walk == input ? walk : walk-1);
 }
 
-static void push_part(const char *input, const int n) {
-       if (first_push)
-               first_push = false;
-       else
-               strncpy(output+strlen(output), " | ", strlen(" | "));
-       strncpy(output+strlen(output), input, n);
-}
-
 /*
  * Get battery information from /sys. Note that it uses the design capacity to calculate the percentage,
  * not the full capacity.
@@ -311,6 +303,7 @@ static bool process_runs(const char *path) {
 
 int main(void) {
        char part[512],
+            pathbuf[512],
             *end;
        unsigned int i;
 
@@ -320,24 +313,21 @@ int main(void) {
        create_file(ORDER_BATTERY "battery");
        create_file(ORDER_LOAD "load");
        create_file(ORDER_TIME "time");
+       for (i = 0; i < sizeof(run_watches) / sizeof(char*); i += 2) {
+               sprintf(pathbuf, "%s%s", ORDER_RUN, run_watches[i]);
+               create_file(pathbuf);
+       }
 
        while (1) {
-               memset(output, '\0', sizeof(output));
-               first_push = true;
-
                for (i = 0; i < sizeof(run_watches) / sizeof(char*); i += 2) {
                        sprintf(part, "%s: %s", run_watches[i], (process_runs(run_watches[i+1]) ? "yes" : "no"));
-                       push_part(part, strlen(part));
+                       sprintf(pathbuf, "%s%s", ORDER_RUN, run_watches[i]);
+                       write_to_statusbar(pathbuf, part);
                }
 
-               char *wireless_info = get_wireless_info();
-               write_to_statusbar(ORDER_WLAN "wlan", wireless_info);
-
-               char *eth_info = get_eth_info();
-               write_to_statusbar(ORDER_ETH "eth", eth_info);
-
-               char *battery_info = get_battery_info();
-               write_to_statusbar(ORDER_BATTERY "battery", battery_info);
+               write_to_statusbar(ORDER_WLAN "wlan", get_wireless_info());
+               write_to_statusbar(ORDER_ETH "eth", get_eth_info());
+               write_to_statusbar(ORDER_BATTERY "battery", get_battery_info());
 
                /* Get load */
                int load_avg = open("/proc/loadavg", O_RDONLY);
index 9836dffa70714e33605f0ad9c14191b691416434..e9d4445923267b4da93dce77a0331499a420fa9b 100644 (file)
@@ -1,8 +1,5 @@
 #define BEGINS_WITH(haystack, needle) (strncmp(haystack, needle, strlen(needle)) == 0)
 
-static char output[512];
-static bool first_push = true;
-
 typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
 
 static void cleanup_rbar_dir(void);
@@ -10,7 +7,6 @@ static void write_to_statusbar(const char *name, const char *message);
 static void write_error_to_statusbar(const char *message);
 static void die(const char *fmt, ...);
 static char *skip_character(char *input, char character, int amount);
-static void push_part(const char *input, const int n);
 static char *get_battery_info(void);
 static char *get_wireless_info(void);
 static char *get_ip_address(const char *interface);