summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2009-10-16 20:31:20 +0200
committerMichael Stapelberg <michael@stapelberg.de>2009-10-16 20:31:20 +0200
commit8a66289702bb17c2874497319ea2a2921e7a3e0d (patch)
treefb5f0ad78a526b98deca4bac38ce886e750bff5c /src
parentb88a55ffa6df3d6e48c5814171f6e8e42449b3e9 (diff)
Obey format for run_watches
Diffstat (limited to 'src')
-rw-r--r--src/print_run_watch.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/print_run_watch.c b/src/print_run_watch.c
index 391467e..807e322 100644
--- a/src/print_run_watch.c
+++ b/src/print_run_watch.c
@@ -1,10 +1,27 @@
#include <stdio.h>
+#include <string.h>
#include "i3status.h"
void print_run_watch(const char *title, const char *pidfile, const char *format) {
bool running = process_runs(pidfile);
- printf("%s%s: %s%s",
- (running ? color("#00FF00") : color("#FF0000")),
- title,
- (running ? "yes" : "no"), endcolor());
+ const char *walk;
+
+ printf("%s", (running ? color("#00FF00") : color("#FF0000")));
+
+ for (walk = format; *walk != '\0'; walk++) {
+ if (*walk != '%') {
+ putchar(*walk);
+ continue;
+ }
+
+ if (strncmp(walk+1, "title", strlen("title")) == 0) {
+ printf("%s", title);
+ walk += strlen("title");
+ } else if (strncmp(walk+1, "status", strlen("status")) == 0) {
+ printf("%s", (running ? "yes" : "no"));
+ walk += strlen("status");
+ }
+ }
+
+ printf("%s", endcolor());
}