better documented how scripts should work + refactored sample implementations
authorDieter Plaetinck <dieter@plaetinck.be>
Sun, 26 Apr 2009 14:02:06 +0000 (16:02 +0200)
committerDieter Plaetinck <dieter@plaetinck.be>
Sun, 26 Apr 2009 14:02:06 +0000 (16:02 +0200)
README
extra/download.sh [changed mode: 0644->0755]
extra/history.sh [new file with mode: 0755]
extra/insert_bookmark.sh [changed mode: 0644->0755]
extra/load_url_from_bookmarks.sh [changed mode: 0644->0755]
extra/load_url_from_history.sh
sampleconfig

diff --git a/README b/README
index e58962d..71cec2d 100644 (file)
--- a/README
+++ b/README
@@ -75,6 +75,30 @@ REPO's:
   They may be developing specific features, which get merged into Dieters experimental branch
 
 
+EXTERNAL SCRIPTS
+You can use external scripts with uzbl the following ways:
+1) let uzbl call them. these scripts are called handlers in the uzbl config. used for handling logging history, handling a new download,.. 
+2) call them yourself from inside uzbl.  you can bind keys for this. examples: add new bookmark, load new url,..
+3) if you want to call scripts that have no option, you can trigger them with something like xbindkeys. example: ? (we try to keep all possibilities inside option 1/2)
+
+Scripts that are called by uzbl are passed the following arguments:
+$1 uzbl-config-file
+$2 uzbl-pid
+$3 uzbl-x-window-id
+$4 uzbl_fifo-filename
+.. [ script specific ] (optional)
+
+The script specific arguments are this:
+* history:
+  $5 page url
+  $6 page title
+  $7 date of visit (Y-m-d H:i:s localtime)
+* add bookmark:
+  $5 page url
+  $6 page title
+* download:
+  $5 url
+
 KNOWN BUGS
 - Segfault occurs on shutdown, almost definitely FIFO related (I'm not seeing this bug now, but the warning was here when I forked the code and I haven't touched the FIFO bit)
 - Segfaults when using zoom commands (happens when max zoom already reached?).
old mode 100644 (file)
new mode 100755 (executable)
index 90d0a9f..ff3d8db
@@ -1,3 +1,2 @@
 #!/bin/bash
-# $1 = url of file to download
-wget $1
+wget $5
diff --git a/extra/history.sh b/extra/history.sh
new file mode 100755 (executable)
index 0000000..4047476
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "$7 $5" >> /tmp/uzbl.history
old mode 100644 (file)
new mode 100755 (executable)
index 3df6086..083a4b4
@@ -1,11 +1,9 @@
 #!/bin/bash
-# $1 should be the uri you want to bookmark
 file=bookmarks
 
-[ -z "$1" ] && exit 1
 which zenity &>/dev/null || exit 2
 
-entry=`zenity --entry --text="Add bookmark. add tags at the end, separated by commas" --entry-text="$1"`
+entry=`zenity --entry --text="Add bookmark. add tags at the end, separated by commas" --entry-text="$5"`
 url=`awk '{print $1}' <<< $entry`
 # TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
 echo "$entry" >> $file
old mode 100644 (file)
new mode 100755 (executable)
index dfbbf9a..52e14e2
@@ -1,4 +1,4 @@
 #!/bin/bash
 file=bookmarks
 goto=`awk '{print $1}' $history_file | dmenu` #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.
-[ -n "$goto" ] && echo "uri $goto" > /tmp/uzbl-fifo-name-TODO
+[ -n "$goto" ] && echo "uri $goto" > $4
index bcc2362..559e257 100755 (executable)
@@ -1,4 +1,4 @@
 #!/bin/bash
 history_file=/tmp/uzbl.history
 goto=`awk '{print $3}' $history_file | sort | uniq | dmenu`
-[ -n "$goto" ] && echo "uri $goto" > /tmp/uzbl-fifo-name-TODO
+[ -n "$goto" ] && echo "uri $goto" > $4
index 3a4bae1..b76030f 100644 (file)
@@ -11,7 +11,7 @@
 # from insert mode by combining them with the modkey
 
 [behavior]
-history_file = /tmp/uzbl.history
+history_handler = ./extra/history.sh
 download_handler = ./extra/download.sh
 fifo_dir = /tmp
 always_insert_mode = 0