+// vim:ts=8:expandtab
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
*/
char *color(const char *colorstr) {
static char colorbuf[32];
+ if (!use_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);
#else
(void)snprintf(colorbuf, sizeof(colorbuf), "%s %s ", colorstr, wmii_normcolors);
#endif
return colorbuf;
}
+/*
+ * Some color formats (xmobar) require to terminate colors again
+ *
+ */
+char *endcolor() {
+#ifdef XMOBAR
+ return "</fc>";
+#else
+ return "";
+#endif
+}
+
/*
* Cleans wmii's /rbar directory by deleting all regular files
*
*/
void cleanup_rbar_dir() {
-#ifdef DZEN
+#if defined(DZEN) || defined(XMOBAR)
return;
#endif
struct dirent *ent;
*
*/
void create_file(const char *name) {
-#ifdef DZEN
+#if defined(DZEN) || defined(XMOBAR)
return;
#endif
char pathbuf[strlen(wmii_path)+256+1];
unsigned int i;
char pathbuf[512];
-#ifndef DZEN
+#if !defined(DZEN) && !defined(XMOBAR)
struct stat statbuf;
/* Wait until wmii_path/rbar exists */
for (; stat(wmii_path, &statbuf) < 0; sleep(interval));
#endif
+#define cf(orderidx, name) create_file(order_to_str(order[orderidx], name));
cleanup_rbar_dir();
if (wlan_interface)
- create_file(concat(order[ORDER_WLAN],"wlan"));
+ cf(ORDER_WLAN, "wlan");
if (eth_interface)
- create_file(concat(order[ORDER_ETH],"eth"));
+ cf(ORDER_ETH, "eth");
if (get_cpu_temperature)
- create_file(concat(order[ORDER_CPU_TEMPERATURE], "cpu_temperature"));
- create_file(concat(order[ORDER_LOAD],"load"));
+ cf(ORDER_CPU_TEMPERATURE, "cpu_temperature");
+ cf(ORDER_LOAD, "load");
if (time_format)
- create_file(concat(order[ORDER_TIME],"time"));
+ cf(ORDER_TIME, "time");
for (i = 0; i < num_run_watches; i += 2) {
- snprintf(pathbuf, sizeof(pathbuf), "%s%s", order[ORDER_RUN], run_watches[i]);
+ snprintf(pathbuf, sizeof(pathbuf), "%d%s", order[ORDER_RUN], run_watches[i]);
create_file(pathbuf);
}
}
exit(1);
}
return;
+#elif XMOBAR
+ if (final_entry) {
+ if (printf("%s\n", message) < 0) {
+ perror("printf");
+ exit(1);
+ }
+
+ fflush(stdout);
+ return;
+ }
+ if (printf("%s" BAR, message) < 0) {
+ perror("printf");
+ exit(1);
+ }
+ return;
+
#endif
char pathbuf[strlen(wmii_path)+256+1];