diff options
author | Karel Kočí <cynerd@email.cz> | 2017-10-20 18:10:08 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-10-20 18:10:08 +0200 |
commit | e908c03fe775787c048ead719220e64b5af8bfe6 (patch) | |
tree | 59acfa1f8b95db60de9ebab0ba9d256735c5b4c7 | |
parent | 1254632045b0879f7149727324859d0951faa427 (diff) | |
download | myconfigs-e908c03fe775787c048ead719220e64b5af8bfe6.tar.gz myconfigs-e908c03fe775787c048ead719220e64b5af8bfe6.tar.bz2 myconfigs-e908c03fe775787c048ead719220e64b5af8bfe6.zip |
Update surf configuration
-rw-r--r-- | config/i3/config | 2 | ||||
-rwxr-xr-x | local/bin/surf-menu | 39 | ||||
-rw-r--r-- | surf/script.js | 1 |
3 files changed, 31 insertions, 11 deletions
diff --git a/config/i3/config b/config/i3/config index 509d182..cbd0b53 100644 --- a/config/i3/config +++ b/config/i3/config @@ -22,7 +22,7 @@ font pango:monospace 8 # Use Mouse+$mod to drag floating windows to their wanted position floating_modifier $mod -# start a terminal +# start a terminal and more bindsym $mod+Return exec urxvt bindsym $mod+Shift+Return exec conkeror & pidgin bindsym $mod+Shift+d exec surf-menu diff --git a/local/bin/surf-menu b/local/bin/surf-menu index bd13e6b..f4925f8 100755 --- a/local/bin/surf-menu +++ b/local/bin/surf-menu @@ -3,17 +3,27 @@ set -e BOOKMARDS=~/notes/bookmarks.md -# Note: Bookmarks starts with '* ' -sed -n 's/\* //p' "$BOOKMARDS" | dmenu -p 'surf' | while read L; do - if echo "$L" | grep -qE '^\?'; then # We do search on duckduckgo +run() { + echo "Run $1" + echo "$1" | grep -qE '^~?/' || true + echo $? + if echo "$1" | grep -qE '^\?'; then # We do search on duckduckgo - surf "https://duckduckgo.com/?q=${L#?}&t=surf&kk=-1&ia=web" + surf "https://duckduckgo.com/?q=${L#?}&t=surf&kk=-1&ia=web" & + + elif echo "$1" | grep -qE '^~?/'; then # This is local path + + surf "${1/#\~/$HOME}" & + + elif echo "$1" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then # This ipv4 address + + surf "$1" & else # We follow address - LPROTOCOL="$(echo "$L" | sed -n 's#^\([^:]*\)://.*#\1#p')" - LHOST="$(echo "$L" | sed -n 's#^[^:]*://##;s#^\([^/]\+\)/\?.*#\1#p')" - LPATH="$(echo "$L" | sed 's#^[^:]*://##;s#^[^/]\+/\?##')" + LPROTOCOL="$(echo "$1" | sed -n 's#^\([^:]*\)://.*#\1#p')" + LHOST="$(echo "$1" | sed -n 's#^[^:]*://##;s#^\([^/]\+\)/\?.*#\1#p')" + LPATH="$(echo "$1" | sed 's#^[^:]*://##;s#^[^/]\+/\?##')" # Try to lookup if it's an real address # Note: This is hack because of youtube, nslookup return No answer but @@ -36,8 +46,17 @@ sed -n 's/\* //p' "$BOOKMARDS" | dmenu -p 'surf' | while read L; do fi fi - surf "$LPROTOCOL://$LHOST/$LPATH" & # run backgrounded + surf "$LPROTOCOL://$LHOST/$LPATH" & fi - -done +} + +if [ -n "$1" ]; then + run "$1" + exit +else + # Note: Bookmarks starts with '* ' + sed -n 's/\* //p' "$BOOKMARDS" | dmenu -p 'surf' | while read L; do + run "$L" + done +fi diff --git a/surf/script.js b/surf/script.js index 36ff8a6..07bbbe6 100644 --- a/surf/script.js +++ b/surf/script.js @@ -70,6 +70,7 @@ elink_setup = function() { } // TODO + // Just to be sure that we override website settings if(document.readyState!="complete") { window.setTimeout("elink_setup()",200); } |