summaryrefslogtreecommitdiff
path: root/src/output.c
blob: d4d8c2f441d3ff02c91425a3827e7c98ec98c7b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// vim:ts=8:expandtab
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>

#include "i3status.h"

/*
 * Returns the correct color format for dzen (^fg(color)) or xmobar (<fc=color>)
 *
 */
char *color(const char *colorstr) {
        static char colorbuf[32];
        if (!cfg_getbool(cfg_general, "colors")) {
                colorbuf[0] = '\0';
                return colorbuf;
        }
#ifdef DZEN
        (void)snprintf(colorbuf, sizeof(colorbuf), "^fg(%s)", colorstr);
#elif XMOBAR
        (void)snprintf(colorbuf, sizeof(colorbuf), "<fc=%s>", colorstr);
#endif
        return colorbuf;
}

/*
 * Some color formats (xmobar) require to terminate colors again
 *
 */
char *endcolor() {
#ifdef XMOBAR
        return "</fc>";
#else
        return "";
#endif
}

void print_seperator() {
#if defined(DZEN) || defined(XMOBAR)
        printf("%s", BAR);
#endif
}