From 915fe7215d0f2202acec0258562c62d1bf4215f9 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 3 Oct 2010 23:29:59 -0400 Subject: Accept a file to use as an argument --- examples/data/scripts/per-site-settings.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'examples/data/scripts/per-site-settings.py') 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: # # # @@ -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) -- cgit v1.2.3