diff options
Diffstat (limited to 'examples/scripts')
-rwxr-xr-x | examples/scripts/cookies.sh | 62 | ||||
-rwxr-xr-x | examples/scripts/insert_bookmark.sh | 6 | ||||
-rwxr-xr-x | examples/scripts/load_url_from_bookmarks.sh | 6 |
3 files changed, 67 insertions, 7 deletions
diff --git a/examples/scripts/cookies.sh b/examples/scripts/cookies.sh index d147930..69b786f 100755 --- a/examples/scripts/cookies.sh +++ b/examples/scripts/cookies.sh @@ -1,2 +1,62 @@ #!/bin/bash -echo $8 - $9 +# this is an example script of how you could manage your cookies.. +# you probably want your cookies config file in your $XDG_CONFIG_HOME ( eg $HOME/.config/uzbl/cookies) + +# MAYBE TODO: allow user to edit cookie before saving. this cannot be done with zenity :( +# TODO: different cookie paths per config (eg per group of uzbl instances) + +if [ -f /usr/share/uzbl/examples/configs/cookies ] +then + file=/usr/share/uzbl/examples/configs/cookies +else + file=./examples/configs/cookies #useful when developing +fi + +if [ -d $XDG_DATA_HOME/uzbl/cookies ] +then + cookie_dir=$XDG_DATA_HOME/uzbl/cookies +else + cookie_dir=./examples/data +fi + +which zenity &>/dev/null || exit 2 + +uri=$6 +action=$8 # GET/PUT +host=${uri/\/*/} + + + +# $1 = section (TRUSTED or DENY) +# $2 =url +function match () { + sed -n "/$1/,/^\$/p" $file 2>/dev/null | grep -q "^$host" +} + +function readcookie () { + cookie= + while read + do + cookie="$REPLY +" + done +} + +function fetch_cookie () { + cookie=`cat $cookie_dir/$host.cookie` +} + +function store_cookie () { + echo $cookie > $cookie_dir/$host.cookie +} + +if match TRUSTED $host +then + [ $action == PUT ] && readcookie && store_cookie $host + [ $action == GET ] && fetch_cookie && echo "$cookie" +elif ! match DENY $host +then + [ $action == PUT ] && readcookie && zenity --question --title 'Uzbl Cookie handler' --text "Accept cookie from $host ? Contents:\n$cookie" && store_cookie $host + [ $action == GET ] && fetch_cookie && zenity --question --title 'Uzbl Cookie handler' --text "Submit cookie to $host ? Contents:\n$cookie" && echo $cookie +fi +exit 0 diff --git a/examples/scripts/insert_bookmark.sh b/examples/scripts/insert_bookmark.sh index 5d76c35..fe18328 100755 --- a/examples/scripts/insert_bookmark.sh +++ b/examples/scripts/insert_bookmark.sh @@ -1,11 +1,11 @@ #!/bin/bash # you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks) -if [ -f /usr/share/uzbl/examples/bookmarks ] +if [ -f /usr/share/uzbl/examples/data/bookmarks ] then - file=/usr/share/uzbl/examples/bookmarks # you will probably get permission denied errors here. pick a file in your ~ + file=/usr/share/uzbl/examples/data/bookmarks # you will probably get permission denied errors here. pick a file in your ~ else - file=./examples/bookmarks #useful when developing + file=./examples/data/bookmarks #useful when developing fi which zenity &>/dev/null || exit 2 diff --git a/examples/scripts/load_url_from_bookmarks.sh b/examples/scripts/load_url_from_bookmarks.sh index 2a893bf..35c772c 100755 --- a/examples/scripts/load_url_from_bookmarks.sh +++ b/examples/scripts/load_url_from_bookmarks.sh @@ -1,11 +1,11 @@ #!/bin/bash # you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks) -if [ -f /usr/share/uzbl/examples/bookmarks ] +if [ -f /usr/share/uzbl/examples/data/bookmarks ] then - file=/usr/share/uzbl/examples/bookmarks + file=/usr/share/uzbl/examples/data/bookmarks else - file=./examples/bookmarks #useful when developing + file=./examples/data/bookmarks #useful when developing fi goto=`awk '{print $1}' $file | dmenu -i` #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. |