aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Ben Boeckel <MathStuf@gmail.com>2010-08-21 11:36:32 -0400
committerGravatar Ben Boeckel <MathStuf@gmail.com>2010-10-02 11:56:29 -0400
commiteeab3def726000c36cc0ba36ca0506b2eecbaf49 (patch)
tree447c89e3f4659cacf3d55d52a7b1dba4906220ae
parent391ffa73dfa46beea7dff2c9789a5f56a39227c4 (diff)
Migrate to using uzbl-args util script
-rwxr-xr-xexamples/data/scripts/download.sh5
-rwxr-xr-xexamples/data/scripts/formfiller.sh29
-rwxr-xr-xexamples/data/scripts/insert_bookmark.sh5
-rwxr-xr-xexamples/data/scripts/load_url_from_bookmarks.sh5
-rwxr-xr-xexamples/data/scripts/load_url_from_history.sh5
-rwxr-xr-xexamples/data/scripts/session.sh21
6 files changed, 30 insertions, 40 deletions
diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh
index 5b4baa7..f2ee4a8 100755
--- a/examples/data/scripts/download.sh
+++ b/examples/data/scripts/download.sh
@@ -2,14 +2,15 @@
# just an example of how you could handle your downloads
# try some pattern matching on the uri to determine what we should do
+source $UZBL_UTIL_DIR/uzbl-args.sh
source $UZBL_UTIL_DIR/uzbl-dir.sh
# Some sites block the default wget --user-agent..
GET="wget --user-agent=Firefox --content-disposition --load-cookies=$UZBL_COOKIE_JAR"
-url="$8"
+url="$1"
-http_proxy="$9"
+http_proxy="$2"
export http_proxy
test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; }
diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh
index 3aa1676..2c792bc 100755
--- a/examples/data/scripts/formfiller.sh
+++ b/examples/data/scripts/formfiller.sh
@@ -49,6 +49,7 @@ else
LINES=""
fi
+source $UZBL_UTIL_DIR/uzbl-args.sh
source $UZBL_UTIL_DIR/uzbl-dir.sh
PROMPT="Choose profile"
@@ -66,23 +67,9 @@ if [ -z "${editor}" ]; then
fi
fi
-config=$1;
-shift
-pid=$1;
-shift
-xid=$1;
-shift
-fifo=$1;
-shift
-socket=$1;
-shift
-url=$1;
-shift
-title=$1;
-shift
action=$1
-domain=$(echo $url | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/')
+domain=$(echo $UZBL_URL | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/')
if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$action" != 'add' -a "$action" != 'once' ]; then
action="new"
@@ -168,14 +155,14 @@ if [ "$action" = 'load' ]; then
sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g')
printf '%s\n' "${fields}" | \
sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \
- sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo
+ sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $UZBL_FIFO
printf '%s\n' "${fields}" | \
sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \
- sed -e 's/@/\\@/g' > $fifo
+ sed -e 's/@/\\@/g' > $UZBL_FIFO
elif [ "$action" = "once" ]; then
tmpfile=$(mktemp)
printf 'js %s dump(); \n' "$dumpFunction" | \
- socat - unix-connect:$socket | \
+ socat - unix-connect:$UZBL_SOCKET | \
sed -n '/^[^(]\+([^)]\+):/p' > $tmpfile
echo "$MODELINE" >> $tmpfile
${editor} $tmpfile
@@ -193,10 +180,10 @@ elif [ "$action" = "once" ]; then
sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g')
printf '%s\n' "${fields}" | \
sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \
- sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo
+ sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $UZBL_FIFO
printf '%s\n' "${fields}" | \
sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \
- sed -e 's/@/\\@/g' > $fifo
+ sed -e 's/@/\\@/g' > $UZBL_FIFO
rm -f $tmpfile
else
if [ "$action" = 'new' -o "$action" = 'add' ]; then
@@ -219,7 +206,7 @@ else
# passwd(password):
#
printf 'js %s dump(); \n' "$dumpFunction" | \
- socat - unix-connect:$socket | \
+ socat - unix-connect:$UZBL_SOCKET | \
sed -n '/^[^(]\+([^)]\+):/p' >> $UZBL_FORMS_DIR/$domain
fi
[ -e "$UZBL_FORMS_DIR/$domain" ] || exit 3 #this should never happen, but you never know.
diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh
index 201bae0..18f643f 100755
--- a/examples/data/scripts/insert_bookmark.sh
+++ b/examples/data/scripts/insert_bookmark.sh
@@ -6,10 +6,9 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh
[ -w "$UZBL_BOOKMARKS_FILE" ] || exit 1
which zenity &>/dev/null || exit 2
-url=$6
# replace tabs, they are pointless in titles and we want to use tabs as delimiter.
-title=$(echo "$7" | sed 's/\t/ /')
-entry=$(zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$url $title\t")
+title=$(echo "$UZBL_TITLE" | sed 's/\t/ /')
+entry=$(zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$UZBL_URL $title\t")
exitstatus=$?
if [ $exitstatus -ne 0 ]; then exit $exitstatus; fi
url=$(echo $entry | awk '{print $1}')
diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh
index 9a955ec..3bcb60f 100755
--- a/examples/data/scripts/load_url_from_bookmarks.sh
+++ b/examples/data/scripts/load_url_from_bookmarks.sh
@@ -2,6 +2,7 @@
#NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.
+source $UZBL_UTIL_DIR/uzbl-args.sh
source $UZBL_UTIL_DIR/uzbl-dir.sh
[ -r "$UZBL_BOOKMARKS_FILE" ] || exit 1
@@ -17,5 +18,5 @@ else
goto=$(awk '{print $1}' $UZBL_BOOKMARKS_FILE | $DMENU $COLORS)
fi
-#[ -n "$goto" ] && echo "uri $goto" > $4
-[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$5
+#[ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO
+[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$UZBL_SOCKET
diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh
index 9fea1eb..5aba844 100755
--- a/examples/data/scripts/load_url_from_history.sh
+++ b/examples/data/scripts/load_url_from_history.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+source $UZBL_UTIL_DIR/uzbl-args.sh
source $UZBL_UTIL_DIR/uzbl-dir.sh
[ -r "$UZBL_HISTORY_FILE" ] || exit 1
@@ -20,5 +21,5 @@ else
| sort -u) | $DMENU $COLORS)
fi
-[ -n "$goto" ] && echo "uri $goto" > $4
-#[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$5
+[ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO
+#[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$UZBL_SOCKET
diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh
index 68ce4d4..1585159 100755
--- a/examples/data/scripts/session.sh
+++ b/examples/data/scripts/session.sh
@@ -8,6 +8,7 @@
# and doesn't need to be called manually at any point.
# Add a line like 'bind quit = /path/to/session.sh endsession' to your config
+source $UZBL_UTIL_DIR/uzbl-args.sh
source $UZBL_UTIL_DIR/uzbl-dir.sh
[ -d $UZBL_DATA_DIR ] || exit 1
@@ -15,12 +16,12 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh
scriptfile=$0 # this script
UZBL="uzbl-browser -c $UZBL_CONFIG_FILE" # add custom flags and whatever here.
-thisfifo="$4"
-act="$8"
-url="$6"
+act="$1"
-if [ "$act." = "." ]; then
- act="$1"
+# Test if we were run alone or from uzbl
+if [ "x$UZBL_FIFO" = "x" ]; then
+ # Take the old config
+ act="$UZBL_CONFIG"
fi
@@ -38,20 +39,20 @@ case $act in
;;
"endinstance" )
- if [ "$url" != "(null)" ]; then
- echo "$url" >> $UZBL_SESSION_FILE
+ if [ "$UZBL_URL" != "(null)" ]; then
+ echo "$UZBL_URL" >> $UZBL_SESSION_FILE
fi
- echo "exit" > "$thisfifo"
+ echo "exit" > "$UZBL_FIFO"
;;
"endsession" )
mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~"
for fifo in $UZBL_FIFO_DIR/uzbl_fifo_*; do
- if [ "$fifo" != "$thisfifo" ]; then
+ if [ "$fifo" != "$UZBL_FIFO" ]; then
echo "spawn $scriptfile endinstance" > "$fifo"
fi
done
- echo "spawn $scriptfile endinstance" > "$thisfifo"
+ echo "spawn $scriptfile endinstance" > "$UZBL_FIFO"
;;
* ) echo "session manager: bad action"