aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/uzbl/scripts/scheme.py
diff options
context:
space:
mode:
authorGravatar Tom Adams <tom@holizz.com>2009-07-22 00:18:57 +0100
committerGravatar Tom Adams <tom@holizz.com>2009-07-22 00:21:13 +0100
commitfdbc0adb186d0abe0de1e0164c5de9d533748bdd (patch)
treeac39650d6f7ebe2c4fdeddadd5d5c3916c45a0a5 /examples/data/uzbl/scripts/scheme.py
parent77d97f482b887a62458ff1ca90cbe904fee5150c (diff)
Only navigate to URI if scheme_handler doesn't print "USED".
Diffstat (limited to 'examples/data/uzbl/scripts/scheme.py')
-rwxr-xr-xexamples/data/uzbl/scripts/scheme.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/examples/data/uzbl/scripts/scheme.py b/examples/data/uzbl/scripts/scheme.py
index c09db08..dde9ba1 100755
--- a/examples/data/uzbl/scripts/scheme.py
+++ b/examples/data/uzbl/scripts/scheme.py
@@ -2,13 +2,25 @@
import os, subprocess, sys, urlparse
+def detach_open(cmd):
+ # Thanks to the vast knowledge of Laurence Withers (lwithers) and this message:
+ # http://mail.python.org/pipermail/python-list/2006-November/587523.html
+ if not os.fork():
+ null = os.open(os.devnull,os.O_WRONLY)
+ for i in range(3): os.dup2(null,i)
+ os.close(null)
+ subprocess.Popen(cmd)
+
if __name__ == '__main__':
uri = sys.argv[8]
u = urlparse.urlparse(uri)
if u.scheme == 'mailto':
- subprocess.call(['xterm', '-e', 'mail %s' % u.path])
+ detach_open(['xterm', '-e', 'mail %s' % u.path])
elif u.scheme == 'xmpp':
- subprocess.call(['gajim-remote', 'open_chat', uri])
- #elif u.scheme == 'git':
- #os.chdir(os.path.expanduser('~/src'))
- #subprocess.call(['git', 'clone', uri])
+ detach_open(['gajim-remote', 'open_chat', uri])
+ elif u.scheme == 'git':
+ detach_open(['git', 'clone', uri], cwd=os.path.expanduser('~/src'))
+ else:
+ print 'DIY!'
+ exit()
+ print 'USED'