aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-06-09 15:18:56 +0200
committerDon Stewart <dons@cse.unsw.edu.au>2007-06-09 15:18:56 +0200
commit70ed7efda386b1089b295702a4c4fcf56cce1e4c (patch)
tree4c0e9ee594c99b38532d6b768f996d6295f5ce72 /scripts
parentfb067c4bf830eef804b65703368eea3b822a3904 (diff)
downloadXMonadContrib-70ed7efda386b1089b295702a4c4fcf56cce1e4c.tar.gz
XMonadContrib-70ed7efda386b1089b295702a4c4fcf56cce1e4c.tar.xz
XMonadContrib-70ed7efda386b1089b295702a4c4fcf56cce1e4c.zip
Add C script for parsing new logging encoding, and displaying workspace info
darcs-hash:20070609131856-9c5c1-15812fa514ec6e0888ea1e36d3794a452b01090e.gz
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run-xmonad.sh2
-rw-r--r--scripts/xmonad-status.c56
2 files changed, 57 insertions, 1 deletions
diff --git a/scripts/run-xmonad.sh b/scripts/run-xmonad.sh
index aad2526..006d2b5 100755
--- a/scripts/run-xmonad.sh
+++ b/scripts/run-xmonad.sh
@@ -24,7 +24,7 @@ rm -f $PIPE
[ -p $PIPE ] || exit
# launch the external 60 second clock, and launch the workspace status bar
-clock | dzen2 -e '' -x 300 -w 768 -ta r -fg $FG -bg $BG -fn $FONT &
+xmonad-clock | dzen2 -e '' -x 300 -w 768 -ta r -fg $FG -bg $BG -fn $FONT &
xmonad-status < $PIPE | dzen2 -e '' -w 300 -ta l -fg $FG -bg $BG -fn $FONT &
# now go for it
diff --git a/scripts/xmonad-status.c b/scripts/xmonad-status.c
new file mode 100644
index 0000000..9fe7900
--- /dev/null
+++ b/scripts/xmonad-status.c
@@ -0,0 +1,56 @@
+/*
+ Module : xmonad-workspace.c
+ Copyright : (c) Don Stewart 2007
+ License : BSD3-style (see LICENSE)
+
+ Maintainer : dons@cse.unsw.edu.au
+ Stability : stable
+ Portability : portable
+
+ C parser for new workspace format
+
+*/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#define WORKSPACES 9
+
+int main(void) {
+
+ size_t len;
+ char workspaces[WORKSPACES];
+ char buf[1024];
+ char *s, *p, *q, current, *rest;
+ int n, i = 0;
+
+ signal(SIGPIPE, SIG_IGN);
+
+ while (fgets(buf, sizeof(buf), stdin) != NULL) {
+
+ n = strlen(buf);
+ buf[n-1] = '\0';
+ s = buf;
+
+ /* extract tag of current workspace */
+ current = *(char *)strsep(&s,"|");
+ rest = s;
+
+ /* 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]);
+ }
+
+ putchar('\n');
+ fflush(stdout);
+ }
+ return EXIT_SUCCESS;
+}