Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stone <michael@laptop.org>2009-12-09 03:45:32 (GMT)
committer Michael Stone <michael@laptop.org>2009-12-09 03:45:32 (GMT)
commit88a1ff04953df5c40109e9e023d33cb15eb71249 (patch)
treecdce6d4a68a9c063c47b2f6a11eb62d9246224ae
parente77e56f5309a247a96f454bb5516a194dd143cdd (diff)
Add a simple resume subcommand.
-rw-r--r--rainbow/bin/Makefile1
-rwxr-xr-xrainbow/bin/rainbow-resume26
2 files changed, 27 insertions, 0 deletions
diff --git a/rainbow/bin/Makefile b/rainbow/bin/Makefile
index 8a9b30b..143e1d1 100644
--- a/rainbow/bin/Makefile
+++ b/rainbow/bin/Makefile
@@ -2,6 +2,7 @@
install:
install -D -m 0755 rainbow-run $(BINDIR)/rainbow-run
install -D -m 0755 rainbow-easy $(BINDIR)/rainbow-easy
+ install -D -m 0755 rainbow-resume $(BINDIR)/rainbow-resume
install -D -m 0755 rainbow-gc $(BINDIR)/rainbow-gc
install -D -m 0755 rainbow-sugarize $(BINDIR)/rainbow-sugarize
install -D -m 0755 rainbow-xify $(BINDIR)/rainbow-xify
diff --git a/rainbow/bin/rainbow-resume b/rainbow/bin/rainbow-resume
new file mode 100755
index 0000000..b9bb055
--- /dev/null
+++ b/rainbow/bin/rainbow-resume
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+function usage() {
+ echo "sudo $0 RESUME_UID /path/to/program"
+ echo "ex: sudo $0 banking /bin/bash"
+ exit 1
+}
+
+if [ -z "$1" ] || [ -z "$SUDO_USER" ]; then usage || exit 1; fi
+
+RESUME_UID="$1"; shift
+
+if [ -z "$DISPLAY" ]; then
+ DISPLAY=`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`
+fi
+
+exec rainbow-run -s /var/spool/rainbow/2 -u "$SUDO_USER" -c "`pwd`" -f 0 -f 1 -f 2 -E "DISPLAY=$DISPLAY" -E "XAUTHORITY=$XAUTHORITY" -a /usr/bin/rainbow-xify -o audio -o network -r "$RESUME_UID" -- $@