]> git.sur5r.net Git - i3/i3status/blob - src/print_run_watch.c
Obey format for run_watches
[i3/i3status] / src / print_run_watch.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "i3status.h"
4
5 void print_run_watch(const char *title, const char *pidfile, const char *format) {
6         bool running = process_runs(pidfile);
7         const char *walk;
8
9         printf("%s", (running ? color("#00FF00") : color("#FF0000")));
10
11         for (walk = format; *walk != '\0'; walk++) {
12                 if (*walk != '%') {
13                         putchar(*walk);
14                         continue;
15                 }
16
17                 if (strncmp(walk+1, "title", strlen("title")) == 0) {
18                         printf("%s", title);
19                         walk += strlen("title");
20                 } else if (strncmp(walk+1, "status", strlen("status")) == 0) {
21                         printf("%s", (running ? "yes" : "no"));
22                         walk += strlen("status");
23                 }
24         }
25
26         printf("%s", endcolor());
27 }