summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.uzbl/config21
-rwxr-xr-x.uzbl/scripts/load_url_from_surfraw.sh57
-rwxr-xr-x.uzbl/scripts/url_from_surfraw.sh17
3 files changed, 21 insertions, 74 deletions
diff --git a/.uzbl/config b/.uzbl/config
index 2a223c1..4ddf0f6 100644
--- a/.uzbl/config
+++ b/.uzbl/config
@@ -84,7 +84,7 @@ set download_handler = sync_spawn @scripts_dir/download.sh
# Load finish handlers
@on_event LOAD_FINISH @set_status <span foreground="gold">done</span>
-@on_event LOAD_FINISH spawn @scripts_dir/history.sh
+# @on_event LOAD_FINISH spawn @scripts_dir/history.sh
# Switch to insert mode if a (editable) html form is clicked
@on_event FOCUS_ELEMENT sh 'if [ "$1" = INPUT -o "$1" = TEXTAREA -o "$1" = SELECT ]; then echo "@set_mode insert" > $UZBL_FIFO; fi' %s
@@ -239,6 +239,7 @@ set ebind = @mode_bind global,-insert
# open a new window or a new tab (see the on_event NEW_WINDOW settings above)
@cbind w = event REQ_NEW_WINDOW
+@cbind t<tabopen:>_ = sh '$XDG_CONFIG_HOME/uzbl/scripts/url_from_surfraw.sh "%s" "event REQ_NEW_WINDOW"'
# Page movement binds
@cbind j = scroll vertical 20
@@ -284,9 +285,6 @@ set ebind = @mode_bind global,-insert
# Print pages to a printer
@cbind <Ctrl>p = hardcopy
-# Web searching binds
-@cbind ddg<DuckDuckGo:>_ = uri http://duckduckgo.com/?q=%s
-@cbind go<Google:>_ = uri http://google.com/?q=%s
# Handy binds
@cbind s<var:>_<value:>_ = set %1 = %2
@@ -298,21 +296,15 @@ set ebind = @mode_bind global,-insert
# Reload all variables in the config
@cbind !reload = sh "sed '/^# === Post-load misc commands/,$d' \"$UZBL_CONFIG\" | grep '^set ' > \"$UZBL_FIFO\""
-# Uri opening prompts
-@cbind o<uri:>_ = uri %s
-
-# Or have it load the current uri into the keycmd for editing
+@cbind o<open:>_ = sh '$XDG_CONFIG_HOME/uzbl/scripts/url_from_surfraw.sh "%s" "uri"'
@cbind O<uri:\@uri>_ = uri %s
# Mode setting binds
-@cbind i = @set_mode insert
+@cbind i = @set_mode insert
# Hard-bound bookmarks
@cbind gh = uri google.co.uk
-# New window binds
-@cbind t = event REQ_NEW_WINDOW
-
# SSL-ify bindings
@cbind zs = uri \@(echo "$UZBL_URI" | sed -e 's/^http:/https:/')\@
@cbind zS = event REQ_NEW_WINDOW \@(echo "$UZBL_URI" | sed -e 's/^http:/https:/')\@
@@ -449,10 +441,5 @@ sync_spawn_exec @scripts_dir/load_cookies.sh @data_home/uzbl/session-cookies.txt
# Set the "home" page.
set uri = google.co.uk
-# Custom binds
-@bind o = sh 'uri=`$HOME/dotfiles/.uzbl/scripts/load_url_from_surfraw.sh` && echo "uri $uri" > "$UZBL_FIFO"'
-
@on_event DOWNLOAD_COMPLETE spawn @scripts_dir/downloadviewer.sh %s
-# @on_event LOAD_COMMIT spawn @scripts_dir/adblock.py
-# @on_event LOAD_COMMIT script @sdir/adblock.js
# vim: set fdm=syntax:
diff --git a/.uzbl/scripts/load_url_from_surfraw.sh b/.uzbl/scripts/load_url_from_surfraw.sh
deleted file mode 100755
index 641ca3c..0000000
--- a/.uzbl/scripts/load_url_from_surfraw.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-# Default search engine. If we really are at a loss, use this
-DEFAULT_SEARCH=google
-
-# The location of the surfraw bookmark file
-BOOKMARKS="$HOME/.surfraw.bookmarks"
-
-# Colors for dmenu
-COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
-
-# Prompt for dmenu
-PROMPT="Open"
-
-# Use surfraw to search for the words
-function search()
-{
- # Does surfraw know what to do with it?
- url=`surfraw -print $@`
-
- # If not, then use the default search engine
- if [ $? -ne 0 ]
- then
- url=`surfraw -print $DEFAULT_SEARCH $@`
- fi
-
- echo $url
-}
-
-# We assume that this is a URL
-function goto()
-{
- case "$1" in
- *:*) echo $1 ;;
- *) echo "http://$1" ;;
- esac
-}
-
-# Use dmenu to navigate through possible choices
-function present_menu()
-{
- elvi=`surfraw -elvi | cut -f 1 | tail --lines=+2`
- if [ -r "$BOOKMARKS" ]
- then
- bookmarks=" `cut -f 1 -d ' ' "$BOOKMARKS" 2>/dev/null`"
- else
- bookmarks=""
- fi
-
- echo "${elvi}${bookmarks}" | tr ' ' '\n' | sort | dmenu -p "$PROMPT" -i $COLORS
-}
-
-present_menu | \
- ( read car cdr
-test -z "$car" && exit 1
-( test -z "$cdr" && echo $car | fgrep -c '.
-:' > /dev/null && goto $car ) || search "$car $cdr" )
diff --git a/.uzbl/scripts/url_from_surfraw.sh b/.uzbl/scripts/url_from_surfraw.sh
new file mode 100755
index 0000000..bf3c501
--- /dev/null
+++ b/.uzbl/scripts/url_from_surfraw.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+DEFAULT_SEARCH=startpage
+string=$1
+cmd=$2
+set -- $string
+is_elvi=$(surfraw -elvi | grep -c "^$1\s")
+nbr_words=$(echo "$string" | wc -w)
+if [ "$nbr_words" -eq 1 ] && [ "$is_elvi" -eq 0 ] && ([[ "$string" == *.* ]] || [[ "$string" == *:* ]])
+then
+ url="$1"
+elif [ $is_elvi -eq 1 ]
+then
+ url="$(surfraw -print $string)"
+else
+ url="$(surfraw -print $DEFAULT_SEARCH $string)"
+fi
+echo "$cmd $url" > $UZBL_FIFO