X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fauto_detect_format.c;h=299614a0ba7ef6c27c57895d81d1630f0c3a4d11;hb=7728c35401cf53dc87832c9bb1b0bfe32fa1ed92;hp=b8dfdfc0231b92ee052fcc62917e37bcb93c76cd;hpb=7ab9167536e4ca0ccb5c5a797e693c484e0456d6;p=i3%2Fi3status diff --git a/src/auto_detect_format.c b/src/auto_detect_format.c index b8dfdfc..299614a 100644 --- a/src/auto_detect_format.c +++ b/src/auto_detect_format.c @@ -74,6 +74,19 @@ char *auto_detect_format() { if (!parentname) goto out; + /* Some shells, for example zsh, open a pipe in a way which will make the + * pipe target the parent process of i3status. If we detect that, we set + * the format and we are done. */ + if (strcasecmp(parentname, "i3bar") == 0) + format = "none"; + else if (strcasecmp(parentname, "dzen2") == 0) + format = "dzen2"; + else if (strcasecmp(parentname, "xmobar") == 0) + format = "xmobar"; + + if (format) + goto out; + rewinddir(dir); while ((entry = readdir(dir)) != NULL) { @@ -136,6 +149,9 @@ char *auto_detect_format() { } out: + if (parentname) + free(parentname); + closedir(dir); return format;