[hackers] [wmii] Make sure that $PLAN9 is set if running rc.wmii, remove .0 from $DISPLAY for sockets. Add P9PATHS config.mk knob for packagers.

From: Kris Maglione <jg_AT_suckless.org>
Date: Thu Mar 22 05:53:07 2007

changeset: 2022:50fe90adbad6
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Thu Mar 22 00:52:14 2007 -0400
summary: Make sure that $PLAN9 is set if running rc.wmii, remove .0 from $DISPLAY for sockets. Add P9PATHS config.mk knob for packagers.

diff -r 94d54c5553d1 -r 50fe90adbad6 Makefile
--- a/Makefile Wed Mar 21 23:31:36 2007 -0400
+++ b/Makefile Thu Mar 22 00:52:14 2007 -0400
@@ -63,6 +63,7 @@ install: all
         @for i in ${SCRIPTS}; do \
                 sed "s|CONFPREFIX|${CONFPREFIX}|g; \
                      s|CONFVERSION|${CONFVERSION}|g; \
+ s|P9PATHS|${P9PATHS}|g; \
                      s|AWKPATH|${AWKPATH}|g" \
                         $$i \
>${DESTDIR}${PREFIX}/bin/$$i; \
diff -r 94d54c5553d1 -r 50fe90adbad6 config.mk
--- a/config.mk Wed Mar 21 23:31:36 2007 -0400
+++ b/config.mk Thu Mar 22 00:52:14 2007 -0400
@@ -9,6 +9,7 @@ CONFPREFIX = ${PREFIX}/etc
 CONFPREFIX = ${PREFIX}/etc
 MANPREFIX = ${PREFIX}/share/man
 AWKPATH = /usr/bin/awk
+P9PATHS = /usr/local/plan9 /usr/local/9 /opt/plan9 /opt/9 /usr/plan9 /usr/9
 
 X11INC = /usr/X11R6/include
 X11LIB = /usr/X11R6/lib
diff -r 94d54c5553d1 -r 50fe90adbad6 main.c
--- a/main.c Wed Mar 21 23:31:36 2007 -0400
+++ b/main.c Thu Mar 22 00:52:14 2007 -0400
@@ -248,7 +248,7 @@ check_9pcon(IXPConn *c) {
 
 int
 main(int argc, char *argv[]) {
- char *wmiirc, *errstr, *tmp;
+ char *wmiirc, *errstr, *tmp, *display;
         char address[1024], ns_path[1024];
         struct passwd *passwd;
         WMScreen *s;
@@ -259,10 +259,12 @@ main(int argc, char *argv[]) {
         passwd = getpwuid(getuid());
         user = estrdup(passwd->pw_name);
         wmiirc = "wmiistartrc";
-
         address[0] = '\0';
- if((tmp = getenv("WMII_ADDRESS")) && strlen(tmp) > 0)
- strncpy(address, tmp, sizeof(address));
+
+ display = strdup(getenv("DISPLAY"));
+ if((tmp = strstr(display, ".0")) == display + strlen(display) - 2)
+ *tmp = '\0';
+
 
         /* command line args */
         for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
@@ -292,16 +294,22 @@ main(int argc, char *argv[]) {
                 }
         }
 
+
+ if((strlen(address) == 0)
+ && (tmp = getenv("WMII_ADDRESS")) && strlen(tmp) > 0)
+ strncpy(address, tmp, sizeof(address));
+
         if(strncmp(address, "unix!", 5) == 0) {
                 tmp = &address[5];
                 i = strrchr(tmp, '/') - tmp;
                 if(i < 0)
                         fatal("wmiiwm: Bad address\n");
                 strncpy(ns_path, tmp, min(sizeof(ns_path), i));
- }else if((tmp = getenv("WMII_NS_DIR")) && strlen(tmp) > 0)
+ }
+ else if((tmp = getenv("WMII_NS_DIR")) && strlen(tmp) > 0)
                 strncpy(ns_path, tmp, sizeof(ns_path));
         else
- snprintf(ns_path, sizeof(ns_path), "/tmp/ns.%s.%s", user, getenv("DISPLAY"));
+ snprintf(ns_path, sizeof(ns_path), "/tmp/ns.%s.%s", user, display);
 
         if(strlen(address) == 0)
                 snprintf(address, sizeof(address), "unix!%s/wmii", ns_path);
diff -r 94d54c5553d1 -r 50fe90adbad6 wmii9rc
--- a/wmii9rc Wed Mar 21 23:31:36 2007 -0400
+++ b/wmii9rc Thu Mar 22 00:52:14 2007 -0400
@@ -1,7 +1,8 @@
 #!/bin/sh -f
 RC=""
-for i in "$PLAN9" /usr/local/plan9 /usr/local/9 /opt/plan9 /opt/9 /usr/plan9 /usr/9; do
+for i in "$PLAN9" P9PATHS; do
         if [ -d "$i" -a -x "$i/bin/rc" ]; then
+ export PLAN9="$i"
                 RC="$i/bin/rc"
                 break;
         fi
@@ -9,7 +10,9 @@ done
 
 if [ ! -n "$RC" ]; then
         exit 1
-elif [ "X$@" != "X" ]; then
+fi
+
+if [ -n "$1" ]; then
         exec $RC $@
 else
         true
Received on Thu Mar 22 2007 - 05:53:07 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:20 UTC