]> git.sur5r.net Git - i3/i3status/blob - src/output.c
3d6666e1409c494baa1829151538e22f5d6dc562
[i3/i3status] / src / output.c
1 // vim:ts=8:expandtab
2 #include <stdbool.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <sys/types.h>
8 #include <fcntl.h>
9 #include <dirent.h>
10
11 #include "i3status.h"
12
13 /*
14  * Returns the correct color format for dzen (^fg(color)) or xmobar (<fc=color>)
15  *
16  */
17 char *color(const char *colorstr) {
18         static char colorbuf[32];
19         if (!cfg_getbool(cfg_general, "colors")) {
20                 colorbuf[0] = '\0';
21                 return colorbuf;
22         }
23         if (output_format == O_DZEN2)
24                 (void)snprintf(colorbuf, sizeof(colorbuf), "^fg(%s)", colorstr);
25         else if (output_format == O_XMOBAR)
26                 (void)snprintf(colorbuf, sizeof(colorbuf), "<fc=%s>", colorstr);
27
28         return colorbuf;
29 }
30
31 /*
32  * Some color formats (xmobar) require to terminate colors again
33  *
34  */
35 char *endcolor() {
36         if (output_format == O_XMOBAR)
37                 return "</fc>";
38         else return "";
39 }
40
41 void print_seperator() {
42         if (output_format == O_DZEN2)
43                 printf("^fg(#333333)^p(5;-2)^ro(2)^p()^fg()^p(5)");
44         else if (output_format == O_XMOBAR)
45                 printf("<fc=#333333> | </fc>");
46         else if (output_format == O_NONE)
47                 printf(" | ");
48 }