summaryrefslogtreecommitdiff
path: root/.uzbl
diff options
context:
space:
mode:
authorUrbain Vaes <urbain@vaes.uk>2015-08-11 15:58:37 +0200
committerUrbain Vaes <urbain@vaes.uk>2015-08-11 15:58:37 +0200
commit5e17418f1eef06e97bb621edf53530437df8b14f (patch)
treef87466982929a0d0fead9ec97a5e9b017c76bf9e /.uzbl
parent8df9472e0cdbab0d12211c2bc77918e8f515c409 (diff)
Back up several files
Diffstat (limited to '.uzbl')
-rw-r--r--.uzbl/config23
-rwxr-xr-x.uzbl/scripts/adblock.py86
-rwxr-xr-x.uzbl/scripts/downloadviewer.sh7
-rwxr-xr-x.uzbl/scripts/goup.pl24
-rwxr-xr-x.uzbl/scripts/mytest.sh14
-rwxr-xr-x.uzbl/scripts/ytdl.sh8
6 files changed, 123 insertions, 39 deletions
diff --git a/.uzbl/config b/.uzbl/config
index 5539181..bb71fec 100644
--- a/.uzbl/config
+++ b/.uzbl/config
@@ -39,7 +39,7 @@ set set_mode = set mode =
set set_status = set status_message =
# Spawn path shortcuts. In spawn the first dir+path match is used in "dir1:dir2:dir3:executable"
-set scripts_dir = /home/urbain/dotfiles/config/uzbl/scripts:@data_home/uzbl:@prefix/share/uzbl/examples/data:scripts
+set scripts_dir = /home/urbain/dotfiles/.uzbl:@data_home/uzbl:@prefix/share/uzbl/examples/data:scripts
## Hardcoded handlers
@@ -359,17 +359,6 @@ set follow_hint_keys = uhetonasidpgcr
@cbind F* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'newwindow') >\@
@cbind fL* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'returnuri') >\@ set
@cbind FL* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'returnuri') >\@ clipboard
-@cbind fi = spawn @scripts_dir/go_input.sh
-
-@cbind fs = spawn @scripts_dir/follow.sh \@< uzbl.follow.followSelection('returnuri') >\@ set
-@cbind fS = spawn @scripts_dir/follow.sh \@< uzbl.follow.followSelection('click') >\@
-@cbind Fs = spawn @scripts_dir/follow.sh \@< uzbl.follow.followSelection('newwindow') >\@
-@cbind FS = spawn @scripts_dir/follow.sh \@< uzbl.follow.followSelection('returnuri') >\@ clipboard
-
-@cbind ft* = spawn @scripts_dir/follow.sh \@< uzbl.follow.followTextContent("%s", 'returnuri') >\@ set
-@cbind fT* = spawn @scripts_dir/follow.sh \@< uzbl.follow.followTextContent("%s", 'click') >\@
-@cbind Ft* = spawn @scripts_dir/follow.sh \@< uzbl.follow.followTextContent("%s", 'newwindow') >\@
-@cbind FT* = spawn @scripts_dir/follow.sh \@< uzbl.follow.followTextContent("%s", 'returnuri') >\@ clipboard
@cbind '* = spawn @scripts_dir/follow.sh \@< uzbl.follow.followTextContent("%s", 'click') >\@
@@ -422,9 +411,6 @@ menu_add Quit uzbl = exit
# Link context menu
menu_link_add Print Link = print \@SELECTED_URI
-# Go up one dir
-@cbind gu = spawn @scripts_dir/goup.pl
-
# Mode configuration
# Define some mode specific uzbl configurations.
@@ -496,4 +482,11 @@ bind 'aur _ = sh 'surfraw -g $8 %s' aur
bind 'freshmeat _ = sh 'surfraw -g $8 %s' freshmeat
bind 'weather _ = sh 'surfraw -g $8 %s' weather
+# Custom binds
+@cbind gu = spawn @scripts_dir/test.sh
+@cbind gU = spawn @scripts_dir/mytest.sh
+@cbind ytdl = sh '$HOME/dotfiles/.uzbl/scripts/ytdl.sh "$UZBL_URI"'
+
+@on_event DOWNLOAD_COMPLETE spawn @scripts_dir/downloadviewer.sh %s
+@on_event LOAD_COMMIT spawn @scripts_dir/adblock.py
# vim: set fdm=syntax:
diff --git a/.uzbl/scripts/adblock.py b/.uzbl/scripts/adblock.py
new file mode 100755
index 0000000..aae39f4
--- /dev/null
+++ b/.uzbl/scripts/adblock.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+import os
+from sys import argv
+from urlparse import urlparse
+
+# This is the original adblock.py script from http://www.uzbl.org/wiki/adblock
+# Nothing was modified. This script is here just to have everything at one place.
+
+def xdghome(key, default):
+ '''Attempts to use the environ XDG_*_HOME paths if they exist otherwise
+ use $HOME and the default path.'''
+
+ xdgkey = "XDG_%s_HOME" % key
+ if xdgkey in os.environ.keys() and os.environ[xdgkey]:
+ return os.environ[xdgkey]
+
+ return os.path.join(os.environ['HOME'], default)
+
+# Setup xdg paths.
+DATA_DIR = os.path.join(xdghome('DATA', '.local/share/'), 'uzbl/')
+
+# Blockfile location.
+BLOCKFILE = os.path.join(DATA_DIR, 'adblock')
+
+JAVASCRIPT = ' '.join(filter(None, map(str.strip, '''
+var uzblAdBlock = function() {
+ var toblock = %s;
+ for(var n = 0; n < toblock.length; n++) {
+ var items;
+ while (1) {
+ try {
+ items = document.evaluate(toblock[n], document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
+ if (items == null) { break; }
+ var i = items.iterateNext();
+ if (i == null) { break; }
+ i.parentNode.removeChild(i);
+ } catch (e) {
+ break;
+ }
+ }
+ }
+};
+'''.split('\n'))))
+
+
+def get_domain(url):
+ '''Return domain segment of url.'''
+
+ if not url.startswith('http'):
+ url = "http://%s" % url
+
+ loc = urlparse(url).netloc
+ if loc.startswith('www.'):
+ loc = loc[4:]
+
+ return loc
+
+
+def adblock(url, fifo):
+ fh = open(BLOCKFILE, 'r')
+ lines = [line.strip() for line in fh.readlines()]
+ fh.close()
+
+ rules, capture = [], False
+ for l in lines:
+ if not l: # newline splits section
+ capture = False
+
+ elif l[0] == '#':
+ continue
+
+ elif capture:
+ rules.append(l)
+
+ elif l[-1] == ':':
+ if get_domain(l[:-1]) == url or l[:-1] == "global":
+ capture = True
+
+ rulestr = repr(rules).replace("@", "\@")
+ js = "js %s\n" % (JAVASCRIPT % rulestr)
+ fh = open(fifo, "w")
+ fh.write(js)
+ fh.close()
+
+if __name__ == '__main__':
+ adblock(get_domain(argv[6]), argv[4])
diff --git a/.uzbl/scripts/downloadviewer.sh b/.uzbl/scripts/downloadviewer.sh
new file mode 100755
index 0000000..306460d
--- /dev/null
+++ b/.uzbl/scripts/downloadviewer.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+case "$1" in
+*.pdf*) zathura "$1" & ;;
+*.jpg*|*.png*|*.jpeg*) feh "$1" & ;;
+*.txt*|*README*|*.pl*|*.sh*|*.py*|*.hs*|*.hl*) urxvt -e vim "$1" & ;;
+*.mov*|*.avi*|*.mpeg*|*.mpg*|*.flv*|*.wmv*|*.mp4*) mplayer "$1" & ;;
+esac
diff --git a/.uzbl/scripts/goup.pl b/.uzbl/scripts/goup.pl
deleted file mode 100755
index f7ae275..0000000
--- a/.uzbl/scripts/goup.pl
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/perl
-
-my ($config,$pid,$xid,$fifo,$socket,$url,$title,$cmd) = @ARGV;
-if($fifo eq "") { die "No fifo"; };
-
-# Delete last slash
-chop($url);
-
-my $index = index(reverse($url), '/');
-
-# if youre already on top of the directory structure
-if ($index == -1)
-{
- print $url;
- exit;
-}
-
-# Workaround for missing reverse index
-$url = (substr(reverse($url), $index, length($url) ));
-$url = reverse($url);
-print $url."\n";
-
-# This could look prettier with native fifo access
-qx(echo "act uri $url" >> $fifo);
diff --git a/.uzbl/scripts/mytest.sh b/.uzbl/scripts/mytest.sh
new file mode 100755
index 0000000..f310e49
--- /dev/null
+++ b/.uzbl/scripts/mytest.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+. "$UZBL_UTIL_DIR/uzbl-dir.sh"
+
+>> "$UZBL_BOOKMARKS_FILE" || exit 1
+
+which zenity >/dev/null 2>&1 || exit 2
+
+tags="$( zenity --entry --text="Enter space-separated tags for bookmark $UZBL_URI:" )"
+exitstatus="$?"
+[ "$exitstatus" -eq 0 ] || exit "$exitstatus"
+
+# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
+echo "$UZBL_URI $tags" >> "$UZBL_BOOKMARKS_FILE"
diff --git a/.uzbl/scripts/ytdl.sh b/.uzbl/scripts/ytdl.sh
new file mode 100755
index 0000000..acf327a
--- /dev/null
+++ b/.uzbl/scripts/ytdl.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+cd ~/Downloads # change this line to determine where the file is saved
+python2 youtube-dl -o %\(title\)s.%\(ext\)s "$1" # -o output template is optional
+# play with mplayer after download
+savename=`python2 youtube-dl -o %\(title\)s.%\(ext\)s --get-filename "$1"`
+mplayer -really-quiet "$savename"
+ratpoison -c "echo [ytdl-uzbl] $1 done." # change this line to change how you are notified of a
+ # completed download