aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-06-09 16:02:58 +0200
committerDon Stewart <dons@cse.unsw.edu.au>2007-06-09 16:02:58 +0200
commit7f9bcc415f34b5b8da3ac5d836796de11b1f5564 (patch)
tree22eca5f3f9793225c2ecb1e5d02f705ea88eec3d /scripts
parent70ed7efda386b1089b295702a4c4fcf56cce1e4c (diff)
downloadXMonadContrib-7f9bcc415f34b5b8da3ac5d836796de11b1f5564.tar.gz
XMonadContrib-7f9bcc415f34b5b8da3ac5d836796de11b1f5564.tar.xz
XMonadContrib-7f9bcc415f34b5b8da3ac5d836796de11b1f5564.zip
improve xmonad-status.c
darcs-hash:20070609140258-9c5c1-2db2449086d67fab0b124a7a8dd80d0952668616.gz
Diffstat (limited to 'scripts')
-rw-r--r--scripts/xmonad-status.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/scripts/xmonad-status.c b/scripts/xmonad-status.c
index 9fe7900..0aa45dd 100644
--- a/scripts/xmonad-status.c
+++ b/scripts/xmonad-status.c
@@ -12,6 +12,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
@@ -20,18 +21,16 @@
int main(void) {
- size_t len;
- char workspaces[WORKSPACES];
char buf[1024];
- char *s, *p, *q, current, *rest;
- int n, i = 0;
+ char *s, current, *rest;
+ int i;
signal(SIGPIPE, SIG_IGN);
while (fgets(buf, sizeof(buf), stdin) != NULL) {
- n = strlen(buf);
- buf[n-1] = '\0';
+ i = strlen(buf);
+ buf[i-1] = '\0';
s = buf;
/* extract tag of current workspace */
@@ -40,13 +39,15 @@ int main(void) {
/* split up workspace list */
/* extract just the tags of the workspace list */
- while (i < WORKSPACES) {
- workspaces[i++] = *(char *)strsep(&rest, ",");
- }
-
- /* now print out list */
for (i = 0; i < WORKSPACES; i++) {
- printf(((workspaces[i] == current) ? "[%c]" : " %c "), workspaces[i]);
+ s = (char *)strsep(&rest, ",");
+
+ if (*s == current) {
+ printf("[%c]", *s);
+ } else if (s[2] != ':') { /* filter empty workspaces */
+ printf(" %c ", *s);
+ }
+
}
putchar('\n');