aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-08-25 22:21:20 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-08-25 22:21:20 +0200
commitcbdf7cf74b708e717dfe79d0cfc470ecfa93f520 (patch)
tree7f36e73da7b302a855339bc74d8239b9d751fdfc /examples
parentfa4f3430215808ae4f9af78f00869e9a96b244ef (diff)
parent948630efe45e6573e02ac142855229fb3198d480 (diff)
merge holizz' scheme handler
Diffstat (limited to 'examples')
-rw-r--r--examples/config/uzbl/config1
-rwxr-xr-xexamples/data/uzbl/scripts/scheme.py23
2 files changed, 24 insertions, 0 deletions
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index ab2cf7f..04e482b 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -9,6 +9,7 @@ set download_handler = spawn $XDG_DATA_HOME/uzbl/scripts/download.sh
set cookie_handler = spawn $XDG_DATA_HOME/uzbl/scripts/cookies.py
#set new_window = sh 'echo uri "$8" > $4' # open in same window
set new_window = sh 'uzbl -u $8' # equivalent to the default behaviour
+set scheme_handler = spawn $XDG_DATA_HOME/uzbl/scripts/scheme.py
set load_start_handler = set status_message = <span foreground="khaki">wait</span>
set load_commit_handler = set status_message = <span foreground="green">recv</span>
set load_finish_handler = set status_message = <span foreground="gold">done</span>
diff --git a/examples/data/uzbl/scripts/scheme.py b/examples/data/uzbl/scripts/scheme.py
new file mode 100755
index 0000000..7286703
--- /dev/null
+++ b/examples/data/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'))