Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stone <michael@laptop.org>2010-09-24 00:41:42 (GMT)
committer Michael Stone <michael@laptop.org>2010-12-19 00:03:19 (GMT)
commit0c730309b939491d4104dfc3cf67662e2fceb7b0 (patch)
treee39951d142fbf6fa17266508ed9ade9b39145252
parent11afc83ff0d2558210065539ba7675f639b9fa04 (diff)
Abstract out the procedure for reading parent environment variables.
-rwxr-xr-xbin/rainbow-easy14
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/rainbow-easy b/bin/rainbow-easy
index dafb9c0..061f5d7 100755
--- a/bin/rainbow-easy
+++ b/bin/rainbow-easy
@@ -10,17 +10,21 @@ if [ -z "$1" ] || [ -z "$SUDO_USER" ]; then usage || exit 1; fi
ID="$1"; shift
-if [ -z "$DISPLAY" ]; then
- DISPLAY=`python <<EOF
+read_parent_envvar () {
+python <<EOF
import os
from os.path import join
ppid = os.getppid()
env = open(join('/proc', str(ppid),'environ')).read().split('\0')
for kv in env:
- if kv.startswith("DISPLAY="):
- print kv[len("DISPLAY="):]
-EOF`
+ if kv.startswith("$1="):
+ print kv[len("$1="):]
+EOF
+}
+
+if [ -z "$DISPLAY" ]; then
+ DISPLAY=`read_parent_envvar DISPLAY`
fi
exec /usr/sbin/rainbow-run \