diff options
Diffstat (limited to '.config/uzbl/scripts/scheme.py')
-rwxr-xr-x | .config/uzbl/scripts/scheme.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/.config/uzbl/scripts/scheme.py b/.config/uzbl/scripts/scheme.py new file mode 100755 index 0000000..7286703 --- /dev/null +++ b/.config/uzbl/scripts/scheme.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +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) + print 'USED' + +if __name__ == '__main__': + uri = sys.argv[8] + u = urlparse.urlparse(uri) + if u.scheme == 'mailto': + detach_open(['xterm', '-e', 'mail %s' % u.path]) + elif u.scheme == 'xmpp': + detach_open(['gajim-remote', 'open_chat', uri]) + elif u.scheme == 'git': + detach_open(['git', 'clone', uri], cwd=os.path.expanduser('~/src')) |