aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/per-site-settings.py
diff options
context:
space:
mode:
authorGravatar Ben Boeckel <MathStuf@gmail.com>2010-10-03 23:29:59 -0400
committerGravatar Ben Boeckel <MathStuf@gmail.com>2010-10-03 23:29:59 -0400
commit915fe7215d0f2202acec0258562c62d1bf4215f9 (patch)
treed8f852183a3b34f3baae39c5af721e45100c8df3 /examples/data/scripts/per-site-settings.py
parentbe07c4f015137b223d25e1e8bb63b7851bc2923e (diff)
Accept a file to use as an argument
Diffstat (limited to 'examples/data/scripts/per-site-settings.py')
-rwxr-xr-xexamples/data/scripts/per-site-settings.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/examples/data/scripts/per-site-settings.py b/examples/data/scripts/per-site-settings.py
index b8c6340..c698592 100755
--- a/examples/data/scripts/per-site-settings.py
+++ b/examples/data/scripts/per-site-settings.py
@@ -1,7 +1,11 @@
#!/usr/bin/env python
# Per-site settings plugin
-# Format of the noscript file:
+# Use like:
+#
+# @on_event LOAD_COMMIT spawn @scripts_dir/per-site-settings.py $XDG_DATA_DIR/per-site-settings
+
+# Format of the settings file:
#
# <url><TAB><path><TAB><command>
#
@@ -20,14 +24,6 @@ import socket
import urlparse
import sys
-def noscript_path():
- env = os.environ
- if 'XDG_DATA_HOME' in env:
- root = env['XDG_DATA_HOME']
- else:
- root = os.path.join(env['HOME'], '.local', 'share')
- return os.path.join(root, 'uzbl', 'per-site-options')
-
def grep_url(url, path, filepath):
entries = []
with open(filepath, 'r') as f:
@@ -48,9 +44,10 @@ def write_to_socket(commands, sockpath):
if __name__ == '__main__':
sockpath = sys.argv[5]
url = urlparse.urlparse(sys.argv[6])
+ filepath = sys.argv[8]
host, path = (url.hostname, url.path)
- commands = grep_url(host, path, noscript_path())
+ commands = grep_url(host, path, filepath)
write_to_socket(commands, sockpath)