2009-07-21 18:26:53 +00:00
|
|
|
// vim:ts=8:expandtab
|
2009-07-21 17:07:30 +00:00
|
|
|
#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"
|
|
|
|
|
|
|
|
/*
|
2009-10-11 20:11:09 +00:00
|
|
|
* Returns the correct color format for dzen (^fg(color)) or xmobar (<fc=color>)
|
2009-07-21 17:07:30 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
char *color(const char *colorstr) {
|
|
|
|
static char colorbuf[32];
|
2009-10-11 20:11:09 +00:00
|
|
|
if (!cfg_getbool(cfg_general, "colors")) {
|
2009-09-26 11:26:13 +00:00
|
|
|
colorbuf[0] = '\0';
|
|
|
|
return colorbuf;
|
|
|
|
}
|
2009-10-24 11:27:02 +00:00
|
|
|
if (output_format == O_DZEN2)
|
2010-06-29 23:59:03 +00:00
|
|
|
(void)snprintf(colorbuf, sizeof(colorbuf), "^fg(%s)", cfg_getstr(cfg_general, colorstr));
|
2009-10-24 11:27:02 +00:00
|
|
|
else if (output_format == O_XMOBAR)
|
2010-06-29 23:59:03 +00:00
|
|
|
(void)snprintf(colorbuf, sizeof(colorbuf), "<fc=%s>", cfg_getstr(cfg_general, colorstr));
|
2009-10-24 11:27:02 +00:00
|
|
|
|
2009-07-21 17:07:30 +00:00
|
|
|
return colorbuf;
|
|
|
|
}
|
|
|
|
|
2009-08-18 19:29:44 +00:00
|
|
|
/*
|
|
|
|
* Some color formats (xmobar) require to terminate colors again
|
|
|
|
*
|
|
|
|
*/
|
2012-05-07 06:27:28 +00:00
|
|
|
char *endcolor(void) {
|
2009-10-24 11:27:02 +00:00
|
|
|
if (output_format == O_XMOBAR)
|
|
|
|
return "</fc>";
|
|
|
|
else return "";
|
2009-08-18 19:29:44 +00:00
|
|
|
}
|
|
|
|
|
2012-05-07 06:27:28 +00:00
|
|
|
void print_seperator(void) {
|
2009-10-24 11:27:02 +00:00
|
|
|
if (output_format == O_DZEN2)
|
2010-06-29 23:59:03 +00:00
|
|
|
printf("^fg(%s)^p(5;-2)^ro(2)^p()^fg()^p(5)", cfg_getstr(cfg_general, "color_separator"));
|
2009-10-24 11:27:02 +00:00
|
|
|
else if (output_format == O_XMOBAR)
|
2010-06-29 23:59:03 +00:00
|
|
|
printf("<fc=%s> | </fc>", cfg_getstr(cfg_general, "color_separator"));
|
2009-10-24 11:27:02 +00:00
|
|
|
else if (output_format == O_NONE)
|
|
|
|
printf(" | ");
|
2009-07-21 17:07:30 +00:00
|
|
|
}
|