diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2009-05-14 23:11:51 +0200 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-05-14 23:11:51 +0200 |
commit | 4482ee0af3813938b437e8b54c2a13267fc955cf (patch) | |
tree | 8d2aa859d547a727abbb1ae72e76618b216beece /examples | |
parent | d5f76f3eaade2e29a4f1541ab539357651c104b3 (diff) |
import whats useful from duclares sample stuff
Diffstat (limited to 'examples')
-rw-r--r-- | examples/duclare/uzbl.conf | 75 | ||||
-rwxr-xr-x | examples/scripts/clipboard.sh (renamed from examples/duclare/clipboard.sh) | 2 | ||||
-rwxr-xr-x | examples/scripts/session.sh (renamed from examples/duclare/session.sh) | 20 |
3 files changed, 11 insertions, 86 deletions
diff --git a/examples/duclare/uzbl.conf b/examples/duclare/uzbl.conf deleted file mode 100644 index 1ce5944..0000000 --- a/examples/duclare/uzbl.conf +++ /dev/null @@ -1,75 +0,0 @@ - -# example uzbl config. in a real config, we should obey the xdg spec - -# all keys in the behavior group are optional. if not set, the corresponding behavior is disabed. -# bindings_internal denote keys to trigger actions internally in uzbl -# bindings_external denote keys to trigger scripts outside uzbl - -# keyboard behavior is vimstyle by default (all actions -> 1 key). set -# always_insert_mode to always be in insert mode and disable going out of it. -# if you do this, make sure you've set a modkey so you can reach the actions -# from insert mode by combining them with the modkey - -[behavior] -history_handler = /home/duclare/.uzbl/history.sh -download_handler = ~/.uzbl/download.sh -cookie_handler = ~/.uzbl/cookie.sh -status_format = <span font_family="monospace"><span background="darkblue" foreground="white">MODE</span> [<span weight="bold" foreground="red">KEYCMD</span>] <span foreground="#606060"> LOAD_PROGRESSBAR </span><span foreground="blue">URI</span> <span foreground="blue" weight="bold">NAME</span></span> -fifo_dir = /tmp -socket_dir = /tmp -always_insert_mode = 0 -modkey = Mod1 -show_status = 1 -status_top = 0 -never_reset_mode = 0 - -[bindings] -# scroll down/up/left/right -j = scroll_vert 40 -k = scroll_vert -40 -h = scroll_horz -20 -l = scroll_horz 20 -b = back -m = forward -s = stop -r = reload -R = reload_ign_cache -w = follow_link_new_window -+ = zoom_in -- = zoom_out -t = toggle_status -#hilight matches -/* = search %s -#jump to next -; = search -gh = uri http://www.uzbl.org -o_ = uri %s -:wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go -ew_ = uri http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=%s&go=Go - -g_ = uri http://www.google.com/search?q=%s -i = insert_mode -B = spawn /home/duclare/.uzbl/insert_bookmark.sh -u = spawn /home/duclare/.uzbl/load_url_from_history.sh -U = spawn /home/duclare/.uzbl/load_url_from_bookmarks.sh -y = spawn /home/duclare/.uzbl/clipboard.sh yank -p = spawn /home/duclare/.uzbl/clipboard.sh goto -W = spawn /home/duclare/.uzbl/launch -ZZ = exit -:q = spawn /home/duclare/.uzbl/session.sh endsession - -# Keyboard based link following: work in progress! No C DOM bindings yet, no click() event for hyperlinks so no referrer set..Quite basic but does the job for now... -# Vimperator-like hints, except that you can't type text to narrow on targets. You can still the text of a link from the beginning, and it'll activate as soon as the word is unique -f* = script var uzblid = 'uzbl_link_hint'; var uzbldivid = uzblid+'_div_container'; var links = document.links; try { HTMLElement.prototype.click = function () {if (typeof this.onclick == 'function') this.onclick({type: 'click'}); } } catch (e) {} function removeOldHints() { var elements = document.getElementById(uzbldivid); if( elements) elements.parentNode.removeChild(elements); } function keyPressHandler(e) {var kC = (window.event) ? event.keyCode : e.keyCode; var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE; if(kC==Esc) removeOldHints();} function isVisible(obj) { if (obj == document) return true; if (!obj) return false; if (!obj.parentNode) return false; if (obj.style) { if (obj.style.display == 'none') return false; if (obj.style.visibility == 'hidden') return false; } return isVisible(obj.parentNode); } function elementPosition(el) { var up = el.offsetTop; var left = el.offsetLeft; var width = el.offsetWidth; var height = el.offsetHeight; while(el.offsetParent) { el = el.offsetParent; up += el.offsetTop; left += el.offsetLeft; } return [up,left,width,height]; } function elementInViewport(el) { offset = elementPosition(el); var up = offset[0]; var left = offset[1]; var width = offset[2]; var height = offset[3]; return (up < (window.pageYOffset + window.innerHeight) && left < (window.pageXOffset + window.innerWidth) && (up + height) > window.pageYOffset && (left + width) > window.pageXOffset); } function generateHints(items, l) { var hintdiv = document.createElement('div'); hintdiv.setAttribute('id', uzbldivid); for (var i=0; i < items.length; i++) { var nr = items[i]; var li = links[nr]; var pos = elementPosition(li); var hint = document.createElement('div'); hint.setAttribute('name',uzblid); var n = (nr+'').length; for (n; n<l; n++) { nr = '0'+nr; } hint.innerText = nr; hint.style.display='inline'; hint.style.backgroundColor='#B9FF00'; hint.style.border='1px solid #4A6600'; hint.style.color='black'; hint.style.zIndex='1000'; hint.style.opacity='0.7'; hint.style.fontSize='11px'; hint.style.fontWeight='bold'; hint.style.lineHeight='9px'; hint.style.margin='0px'; hint.style.padding='1px'; hint.style.position='absolute'; hint.style.left=pos[1]+'px'; hint.style.top=pos[0]+'px'; var img = li.getElementsByTagName('img'); if (img.length>0) { hint.style.left=pos[1]+(img[0].width/2)+'px'; } hint.style.textDecoration='none'; hint.style.webkitBorderRadius='6px'; hint.style.webkitTransform='scale(0.9) rotate(0deg) translate(-6px,-5px)'; hintdiv.appendChild(hint); } document.body.appendChild(hintdiv); } function clickLink(item) { removeOldHints(); if (item) { item.click(); window.location = item.href; } } function followLink(follow) { document.body.setAttribute('onkeyup', 'keyPressHandler(event)'); var s = follow.split(''); var linktexts = [[],[]]; for (var i=0; i < links.length; i++) { var li = links[i]; if (isVisible(li) && elementInViewport(li)) { linktexts[0].push(i); linktexts[1].push(li.innerText); } } var leftovers = []; var nrlength = (linktexts[0][linktexts[0].length-1]+'').length; var linknr = parseInt(follow, 10); if (s.length == nrlength) { clickLink(links[linknr]); } else { for (var j=0; j < linktexts[0].length; j++) { var b = true; for (var k=0; k < s.length; k++) { b = (b && (linktexts[1][j].charAt(k)==s[k])); } if (b) { leftovers.push(linktexts[0][j]); } } if (leftovers.length == 1 && s.length >= nrlength) { clickLink(links[leftovers[0]]); } else if (!document.getElementById(uzbldivid)) { generateHints(linktexts[0], nrlength); } } } followLink('%s'); - -[network] -# to start a local socks server, do : ssh -fND localhost:8118 localhost -#proxy_server = http://127.0.0.1:8118 -#values 0-3 -http_debug = 0 -user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) -# Example user agent containing everything: -#user-agent = Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) -max_conns = -max_conns_per_host = - diff --git a/examples/duclare/clipboard.sh b/examples/scripts/clipboard.sh index a2b3717..c64b65c 100755 --- a/examples/duclare/clipboard.sh +++ b/examples/scripts/clipboard.sh @@ -1,5 +1,7 @@ #!/bin/bash +# with this script you can store the current url in the clipboard, or go to the url which is stored in the clipboard. + fifo="$5" action="$1" url="$7" diff --git a/examples/duclare/session.sh b/examples/scripts/session.sh index 4dd4a39..5087af0 100755 --- a/examples/duclare/session.sh +++ b/examples/scripts/session.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Simple session manager for uzbl. When called with "endsession" as the +# Very simple session manager for uzbl. When called with "endsession" as the # argument, it'lla empty the sessionfile, look for fifos in $fifodir and # instruct each of them to store their current url in $sessionfile and # terminate themselves. Run with "launch" as the argument and an instance of @@ -8,11 +8,9 @@ # and doesn't need to be called manually at any point. -scriptfile=~/.uzbl/session.sh # this script -sessionfile=~/.uzbl/session # the file in which the "session" (i.e. urls) are stored - -# a simple script that calls the executable with --config <cfgpath> and args -launcher=~/.uzbl/launch +scriptfile=$XDG_CONFIG_HOME/uzbl/session.sh # this script +sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored +UZBL="uzbl" # add custom flags and whatever here. fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere thisfifo="$5" @@ -22,15 +20,15 @@ url="$7" case $act in "launch" ) for url in $(cat $sessionfile); do - $launcher --uri "$url" & + $UZBL --uri "$url" & done exit 0;; "endinstance" ) if [ "$url" != "(null)" ]; then - echo "$url" >> $sessionfile; echo "exit" > "$thisfifo" - else - echo "exit" > "$thisfifo" - fi;; + echo "$url" >> $sessionfile; + fi + echo "exit" > "$thisfifo" + ;; "endsession" ) echo -n "" > "$sessionfile" for fifo in $fifodir/uzbl_fifo_*; do |