aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README23
-rw-r--r--examples/config/config8
-rw-r--r--examples/data/plugins/keycmd.py14
-rwxr-xr-xexamples/data/scripts/auth.py2
-rwxr-xr-xexamples/data/scripts/download.sh14
-rwxr-xr-xexamples/data/scripts/formfiller.sh12
-rwxr-xr-xexamples/data/scripts/insert_temp.sh7
-rwxr-xr-xexamples/data/scripts/load_url_from_temps.sh22
-rw-r--r--examples/data/scripts/util/dmenu.sh7
-rw-r--r--examples/data/scripts/util/uzbl-dir.sh1
-rw-r--r--src/callbacks.c8
-rw-r--r--src/uzbl-core.c25
-rw-r--r--src/uzbl-core.h1
13 files changed, 121 insertions, 23 deletions
diff --git a/README b/README
index 431694e..c5d353b 100644
--- a/README
+++ b/README
@@ -257,11 +257,14 @@ The following commands are recognized:
- Show the WebInspector
* `add_cookie <domain> <path> <name> <value> <scheme> <expires>`
- Adds a new cookie to the cookie jar
-* 'delete_cookie <domain> <path> <name> <value> [<scheme> <expires>]`
+* `delete_cookie <domain> <path> <name> <value> [<scheme> <expires>]`
- Deletes a matching cookie from the cookie jar. scheme and expire time
- is currently not considered when matching.
-* 'clear_cookies`
- - Clears all cookies from the cookie jar
+ is currently not considered when matching.
+* `clear_cookies`
+ - Clears all cookies from the cookie jar
+* `download <uri> [<destination path>]`
+ - Starts a download using the given uri. A destination file path can be given
+ to specify where the download should be written to.
### VARIABLES AND CONSTANTS
@@ -506,9 +509,15 @@ Handler scripts (`download_handler`, `cookie_handler`, `scheme_handler` and
* download handler
- `$1 url`: The URL of the item to be downloaded.
- - `$2 suggested_filename`: A filename suggested by the server or based on the URL.
+ - `$2 suggested_filename`: A filename suggested by the server or based on the
+ URL.
- `$3 content_type`: The mimetype of the file to be downloaded.
- - `$4 total_size`: The size of the file to be downloaded in bytes. This may be inaccurate.
+ - `$4 total_size`: The size of the file to be downloaded in bytes. This may be
+ inaccurate.
+ - `$5 destination_path`: This is only present if the download was started
+ explicitly using the `download` command. If it is present, this is the path
+ that the file should be saved to. A download handler using WebKit's internal
+ downloader can just echo this path and exit when this argument is present.
* cookie handler
@@ -764,6 +773,8 @@ Events/requests which the EM and its plugins listens for
keycmd.
* `KEYCMD_STRIP_WORD`: Removes the last word from the keycmd, similar to
readline `^W`.
+ - `request KEYCMD_STRIP_WORD <seps>`: The `<seps>` argument is a list of
+ characters that are considered to separate words.
* `KEYCMD_EXEC_CURRENT`: (tries to) execute whatever is in the keycmd.
* `SET_KEYCMD`: Allow setting of the keycmd externally.
- `request SET_KEYCMD <string>`: Set the keycmd to `<string>`.
diff --git a/examples/config/config b/examples/config/config
index d049f0e..ab789f9 100644
--- a/examples/config/config
+++ b/examples/config/config
@@ -200,7 +200,7 @@ set ebind = @mode_bind global,-insert
@ebind <Delete> = event KEYCMD_DELETE
@ebind <Tab> = event START_COMPLETION
# Readline-ish bindings.
-@ebind <Ctrl>w = event KEYCMD_STRIP_WORD
+@ebind <Ctrl>w = event KEYCMD_STRIP_WORD \ -./&?=
@ebind <Ctrl>u = event SET_KEYCMD
@ebind <Ctrl>a = event SET_CURSOR_POS 0
@ebind <Ctrl>e = event SET_CURSOR_POS -1
@@ -337,6 +337,10 @@ set ebind = @mode_bind global,-insert
@cbind U = spawn @scripts_dir/load_url_from_history.sh
@cbind u = spawn @scripts_dir/load_url_from_bookmarks.sh
+# Temporary bookmarks
+@cbind <Ctrl>d = spawn @scripts_dir/insert_temp.sh
+@cbind D = spawn @scripts_dir/load_url_from_temps.sh
+
# Link following (similar to vimperator and konqueror)
# Set custom keys you wish to use for navigation. Some common examples:
set follow_hint_keys = 0123456789
@@ -353,10 +357,10 @@ set follow_hint_keys = 0123456789
# This implementation allows you to save multiple profiles for each form
# (think about multiple accounts on some website).
set formfiller = spawn @scripts_dir/formfiller.sh
-@cbind za = @formfiller add
@cbind ze = @formfiller edit
@cbind zn = @formfiller new
@cbind zl = @formfiller load
+@cbind zo = @formfiller once
# --- Uzbl tabbed binds ------------------------------------------------------
diff --git a/examples/data/plugins/keycmd.py b/examples/data/plugins/keycmd.py
index 928c597..76e2d75 100644
--- a/examples/data/plugins/keycmd.py
+++ b/examples/data/plugins/keycmd.py
@@ -406,16 +406,22 @@ def append_keycmd(uzbl, keycmd):
update_event(uzbl, k, False)
-def keycmd_strip_word(uzbl, sep):
+def keycmd_strip_word(uzbl, seps):
''' Removes the last word from the keycmd, similar to readline ^W '''
- sep = sep or ' '
+ seps = seps or ' '
k = uzbl.keylet
if not k.keycmd:
return
- head, tail = k.keycmd[:k.cursor].rstrip(sep), k.keycmd[k.cursor:]
- rfind = head.rfind(sep)
+ head, tail = k.keycmd[:k.cursor].rstrip(seps), k.keycmd[k.cursor:]
+ rfind = -1
+ for sep in seps:
+ p = head.rfind(sep)
+ if p >= 0 and rfind < p + 1:
+ rfind = p + 1
+ if rfind == len(head) and head[-1] in seps:
+ rfind -= 1
head = head[:rfind] if rfind + 1 else ''
k.keycmd = head + tail
k.cursor = len(head)
diff --git a/examples/data/scripts/auth.py b/examples/data/scripts/auth.py
index 592a2c6..49fa41e 100755
--- a/examples/data/scripts/auth.py
+++ b/examples/data/scripts/auth.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
import gtk
import sys
diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh
index fe566ed..dbc9caf 100755
--- a/examples/data/scripts/download.sh
+++ b/examples/data/scripts/download.sh
@@ -1,9 +1,17 @@
#!/bin/sh
# uzbl's example configuration sets this script up as its download_handler.
-# when uzbl starts a download it runs this script.
+# this script is run when uzbl encounters a URL that it can't display, and when
+# a download is requested using the 'download' command.
+#
# if the script prints a file path to stdout, uzbl will save the download to
-# that path.
-# if nothing is printed to stdout, the download will be cancelled.
+# that path using it's internal downloader.
+#
+# if nothing is printed to stdout, the internal download will be cancelled.
+# you could do your own download handling in your script that way.
+
+# if $5 is set, it is the path that was passed to uzbl's "download" command.
+# we want to use that if it's available.
+[ -n "$5" ] && echo "$5" && exit
. "$UZBL_UTIL_DIR/uzbl-dir.sh"
diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh
index 3dc9dc4..c1171a0 100755
--- a/examples/data/scripts/formfiller.sh
+++ b/examples/data/scripts/formfiller.sh
@@ -66,22 +66,22 @@ ParseFields ()
field = $0
sub ( /[^:]*:/, "", field )
- if ( parts[2] ~ /(text|password|search)/ )
+ if ( parts[2] ~ /^(text|password|search)$/ )
printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",0);\n",
parts[1], parts[2], field )
- else if ( parts[2] ~ /(checkbox|radio)/ )
+ else if ( parts[2] ~ /^(checkbox|radio)$/ )
printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",%s);\n",
parts[1], parts[2], parts[3], field )
- else if ( parts[2] == "textarea" ) {
+ else if ( parts[2] ~ /^textarea$/ ) {
field = ""
while (getline) {
if ( /^%/ ) break
sub ( /^\\/, "" )
gsub ( /"/, "\\\"" )
gsub ( /\\/, "\\\\" )
- field = field $0 "\\n"
+ field = field $0 "\\\\n"
}
printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",0);\n",
parts[1], parts[2], field )
@@ -116,7 +116,7 @@ Load ()
ParseProfile $option < "$file" \
| ParseFields \
- | sed 's/@/\\@/' \
+ | sed 's/@/\\@/g' \
> "$UZBL_FIFO"
}
@@ -132,7 +132,7 @@ Once ()
test -e "$tmpfile" &&
ParseFields < "$tmpfile" \
- | sed 's/@/\\@' \
+ | sed 's/@/\\@/g' \
> "$UZBL_FIFO"
}
diff --git a/examples/data/scripts/insert_temp.sh b/examples/data/scripts/insert_temp.sh
new file mode 100755
index 0000000..7ed8d22
--- /dev/null
+++ b/examples/data/scripts/insert_temp.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. "$UZBL_UTIL_DIR/uzbl-dir.sh"
+
+>> "$UZBL_TEMPS_FILE" || exit 1
+
+echo "$UZBL_URI $UZBL_TITLE" >> "$UZBL_TEMPS_FILE"
diff --git a/examples/data/scripts/load_url_from_temps.sh b/examples/data/scripts/load_url_from_temps.sh
new file mode 100755
index 0000000..b46687b
--- /dev/null
+++ b/examples/data/scripts/load_url_from_temps.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+DMENU_SCHEME="temps"
+DMENU_OPTIONS="xmms vertical resize"
+
+. "$UZBL_UTIL_DIR/dmenu.sh"
+. "$UZBL_UTIL_DIR/uzbl-dir.sh"
+
+[ -r "$UZBL_TEMPS_FILE" ] || exit 1
+
+if [ -z "$DMENU_HAS_VERTICAL" ]; then
+ # because they are all after each other, just show the url, not their titles.
+ goto=$( awk '{ print $1 }' "$UZBL_TEMPS_FILE" | $DMENU )
+else
+ # show titles
+ goto=$( $DMENU < "$UZBL_TEMPS_FILE" | cut -d ' ' -f 1 )
+fi
+
+sed -i -e "\<^$goto <d" $UZBL_TEMPS_FILE
+
+[ -n "$goto" ] && echo "uri $goto" > "$UZBL_FIFO"
+#[ -n "$goto" ] && echo "uri $goto" | socat - "unix-connect:$UZBL_SOCKET"
diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh
index f0d1651..0b7272e 100644
--- a/examples/data/scripts/util/dmenu.sh
+++ b/examples/data/scripts/util/dmenu.sh
@@ -30,6 +30,13 @@ case "$DMENU_SCHEME" in
SB="#ccffaa"
SF="#303030"
;;
+ # Temps
+ "temps" )
+ NB="#303030"
+ NF="khaki"
+ SB="#ccffaa"
+ SF="#303030"
+ ;;
# Default
* )
NB="#303030"
diff --git a/examples/data/scripts/util/uzbl-dir.sh b/examples/data/scripts/util/uzbl-dir.sh
index 3d28151..82510d8 100644
--- a/examples/data/scripts/util/uzbl-dir.sh
+++ b/examples/data/scripts/util/uzbl-dir.sh
@@ -15,5 +15,6 @@ UZBL_FORMS_DIR="$UZBL_DATA_DIR/dforms"
UZBL_CONFIG_FILE="$UZBL_CONFIG_DIR/config"
UZBL_COOKIE_FILE="$UZBL_DATA_DIR/cookies.txt"
UZBL_BOOKMARKS_FILE="$UZBL_DATA_DIR/bookmarks"
+UZBL_TEMPS_FILE="$UZBL_DATA_DIR/temps"
UZBL_HISTORY_FILE="$UZBL_DATA_DIR/history"
UZBL_SESSION_FILE="$UZBL_DATA_DIR/browser-session"
diff --git a/src/callbacks.c b/src/callbacks.c
index 360b0c4..703107b 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -837,6 +837,11 @@ download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_dat
/* get the URI being downloaded */
const gchar *uri = webkit_download_get_uri(download);
+ /* get the destination path, if specified.
+ * this is only intended to be set when this function is trigger by an
+ * explicit download using uzbl's 'download' action. */
+ const gchar *destination = user_data;
+
if (uzbl.state.verbose)
printf("Download requested -> %s\n", uri);
@@ -883,6 +888,9 @@ download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_dat
gchar *total_size_s = g_strdup_printf("%d", total_size);
g_array_append_val(a, total_size_s);
+ if(destination)
+ g_array_append_val(a, destination);
+
GString *result = g_string_new ("");
run_parsed_command(c, a, result);
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index e918451..c095a7f 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -552,7 +552,8 @@ CommandInfo cmdlist[] =
{ "show_inspector", show_inspector, 0 },
{ "add_cookie", add_cookie, 0 },
{ "delete_cookie", delete_cookie, 0 },
- { "clear_cookies", clear_cookies, 0 }
+ { "clear_cookies", clear_cookies, 0 },
+ { "download", download, 0 }
};
void
@@ -741,6 +742,28 @@ clear_cookies(WebKitWebView *page, GArray *argv, GString *result) {
}
void
+download(WebKitWebView *web_view, GArray *argv, GString *result) {
+ (void) result;
+
+ const gchar *uri = argv_idx(argv, 0);
+ const gchar *destination = NULL;
+ if(argv->len > 1)
+ destination = argv_idx(argv, 1);
+
+ WebKitNetworkRequest *req = webkit_network_request_new(uri);
+ WebKitDownload *download = webkit_download_new(req);
+
+ download_cb(web_view, download, destination);
+
+ if(webkit_download_get_destination_uri(download))
+ webkit_download_start(download);
+ else
+ g_object_unref(download);
+
+ g_object_unref(req);
+}
+
+void
act_dump_config() {
dump_config();
}
diff --git a/src/uzbl-core.h b/src/uzbl-core.h
index affd334..be8fccd 100644
--- a/src/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -325,6 +325,7 @@ void show_inspector(WebKitWebView *page, GArray *argv, GString *result);
void add_cookie(WebKitWebView *page, GArray *argv, GString *result);
void delete_cookie(WebKitWebView *page, GArray *argv, GString *result);
void clear_cookies(WebKitWebView *pag, GArray *argv, GString *result);
+void download(WebKitWebView *pag, GArray *argv, GString *result);
void builtins();
typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result);