summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2009-08-18 21:29:44 +0200
committerMichael Stapelberg <michael@stapelberg.de>2009-08-18 21:29:44 +0200
commitbb52b40c8ed5b3c938f6bb157b08bcb18bb067c2 (patch)
treeb51353978312adc5624872a2f0fbb3e2f0da79d3 /src
parent56312001de9362ced18962149bd8143185214561 (diff)
Add support for xmobar
Use i3status-xmobar | xmobar -o -t "%StdinReader%" -c "[Run StdinReader]" You might need to copy the default configuration to ~/.xmobarrc
Diffstat (limited to 'src')
-rw-r--r--src/config.c5
-rw-r--r--src/get_wireless_info.c6
-rw-r--r--src/output.c36
3 files changed, 39 insertions, 8 deletions
diff --git a/src/config.c b/src/config.c
index 2d9d6b6..19c03e9 100644
--- a/src/config.c
+++ b/src/config.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
+#include <glob.h>
#include "i3status.h"
@@ -80,7 +81,7 @@ int load_configuration(const char *configfile) {
interval = atoi(dest_value);
OPT("wmii_path")
{
-#ifndef DZEN
+#if !defined(DZEN) && !defined(XMOBAR)
static glob_t globbuf;
struct stat stbuf;
if (glob(dest_value, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
@@ -139,7 +140,7 @@ int load_configuration(const char *configfile) {
}
fclose(handle);
-#ifndef DZEN
+#if !defined(DZEN) && !defined(XMOBAR)
if (wmii_path == NULL)
exit(EXIT_FAILURE);
#endif
diff --git a/src/get_wireless_info.c b/src/get_wireless_info.c
index c257f56..529ba71 100644
--- a/src/get_wireless_info.c
+++ b/src/get_wireless_info.c
@@ -34,10 +34,10 @@ const char *get_wireless_info() {
continue;
if ((quality == UCHAR_MAX) || (quality == 0)) {
if (use_colors)
- (void)snprintf(part, sizeof(part), "%sW: down", color("#FF0000"));
+ (void)snprintf(part, sizeof(part), "%sW: down%s", color("#FF0000"), endcolor());
else (void)snprintf(part, sizeof(part), "W: down");
- } else (void)snprintf(part, sizeof(part), "%sW: (%03d%%) %s",
- color("#00FF00"), quality, get_ip_addr(wlan_interface));
+ } else (void)snprintf(part, sizeof(part), "%sW: (%03d%%) %s%s",
+ color("#00FF00"), quality, get_ip_addr(wlan_interface), endcolor());
return part;
}
diff --git a/src/output.c b/src/output.c
index 901a940..c153a01 100644
--- a/src/output.c
+++ b/src/output.c
@@ -28,6 +28,8 @@ char *color(const char *colorstr) {
static char colorbuf[32];
#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
@@ -35,11 +37,23 @@ char *color(const char *colorstr) {
}
/*
+ * 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;
@@ -66,7 +80,7 @@ void cleanup_rbar_dir() {
*
*/
void create_file(const char *name) {
-#ifdef DZEN
+#if defined(DZEN) || defined(XMOBAR)
return;
#endif
char pathbuf[strlen(wmii_path)+256+1];
@@ -99,7 +113,7 @@ void setup(void) {
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));
@@ -142,6 +156,22 @@ void write_to_statusbar(const char *name, const char *message, bool final_entry)
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];