wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 21df75141e77ead31a5487709d67f25427a311ca
parent 323e3fa654c279eb47e2a907c6cfa8d63c46909e
Author: Kris Maglione <jg@suckless.org>
Date:   Thu, 22 Mar 2007 00:52:14 -0400

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

Diffstat:
Makefile | 1+
config.mk | 1+
main.c | 20++++++++++++++------
wmii9rc | 7+++++--
4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile @@ -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 --git a/config.mk b/config.mk @@ -9,6 +9,7 @@ PREFIX = /usr/local 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 --git a/main.c b/main.c @@ -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 --git a/wmii9rc b/wmii9rc @@ -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