diff options
Diffstat (limited to 'examples/data')
-rw-r--r-- | examples/data/plugins/bind.py | 8 | ||||
-rw-r--r-- | examples/data/plugins/history.py | 2 | ||||
-rw-r--r-- | examples/data/plugins/keycmd.py | 218 | ||||
-rwxr-xr-x | examples/data/scripts/auth.py | 2 | ||||
-rwxr-xr-x | examples/data/scripts/download.sh | 14 | ||||
-rw-r--r-- | examples/data/scripts/follow.js | 40 | ||||
-rwxr-xr-x | examples/data/scripts/follow.sh | 22 | ||||
-rw-r--r-- | examples/data/scripts/formfiller.js | 35 | ||||
-rwxr-xr-x | examples/data/scripts/formfiller.sh | 24 | ||||
-rwxr-xr-x | examples/data/scripts/insert_temp.sh | 7 | ||||
-rwxr-xr-x | examples/data/scripts/load_url_from_temps.sh | 22 | ||||
-rw-r--r-- | examples/data/scripts/util/dmenu.sh | 7 | ||||
-rw-r--r-- | examples/data/scripts/util/uzbl-dir.sh | 13 |
13 files changed, 208 insertions, 206 deletions
diff --git a/examples/data/plugins/bind.py b/examples/data/plugins/bind.py index 69fd863..fc8b392 100644 --- a/examples/data/plugins/bind.py +++ b/examples/data/plugins/bind.py @@ -372,11 +372,11 @@ def mode_changed(uzbl, mode): uzbl.bindlet.reset() -def match_and_exec(uzbl, bind, depth, keylet, bindlet): +def match_and_exec(uzbl, bind, depth, modstate, keylet, bindlet): (on_exec, has_args, mod_cmd, glob, more) = bind[depth] cmd = keylet.modcmd if mod_cmd else keylet.keycmd - if mod_cmd and keylet.held != mod_cmd: + if mod_cmd and modstate != mod_cmd: return False if has_args: @@ -415,7 +415,7 @@ def match_and_exec(uzbl, bind, depth, keylet, bindlet): return True -def key_event(uzbl, keylet, mod_cmd=False, on_exec=False): +def key_event(uzbl, modstate, keylet, mod_cmd=False, on_exec=False): bindlet = uzbl.bindlet depth = bindlet.depth for bind in bindlet.get_binds(): @@ -423,7 +423,7 @@ def key_event(uzbl, keylet, mod_cmd=False, on_exec=False): if (bool(t[MOD_CMD]) != mod_cmd) or (t[ON_EXEC] != on_exec): continue - if match_and_exec(uzbl, bind, depth, keylet, bindlet): + if match_and_exec(uzbl, bind, depth, modstate, keylet, bindlet): return bindlet.after() diff --git a/examples/data/plugins/history.py b/examples/data/plugins/history.py index 5e9e4e1..f42f86f 100644 --- a/examples/data/plugins/history.py +++ b/examples/data/plugins/history.py @@ -83,7 +83,7 @@ class History(object): def __str__(self): return "(History %s, %s)" % (self.cursor, self.prompt) -def keycmd_exec(uzbl, keylet): +def keycmd_exec(uzbl, modstate, keylet): cmd = keylet.get_keycmd() if cmd: uzbl.history.add(cmd) diff --git a/examples/data/plugins/keycmd.py b/examples/data/plugins/keycmd.py index 928c597..1bb70e3 100644 --- a/examples/data/plugins/keycmd.py +++ b/examples/data/plugins/keycmd.py @@ -17,13 +17,10 @@ def uzbl_escape(str): class Keylet(object): - '''Small per-instance object that tracks all the keys held and characters - typed.''' + '''Small per-instance object that tracks characters typed.''' def __init__(self): # Modcmd tracking - self.held = set() - self.ignored = set() self.modcmd = '' self.is_modcmd = False @@ -33,7 +30,6 @@ class Keylet(object): self.modmaps = {} self.ignores = {} - self.additions = {} def get_keycmd(self): @@ -48,7 +44,7 @@ class Keylet(object): if not self.is_modcmd: return '' - return ''.join(self.held) + self.modcmd + return self.modcmd def modmap_key(self, key): @@ -65,28 +61,6 @@ class Keylet(object): return key - def find_addition(self, modkey): - '''Key has just been pressed, check if this key + the held list - results in a modkey addition. Return that addition and remove all - modkeys that created it.''' - - # Intersection of (held list + modkey) and additions. - added = (self.held | set([modkey])) & set(self.additions.keys()) - for key in added: - if key == modkey or modkey in self.additions[key]: - self.held -= self.additions[key] - return key - - # Held list + ignored list + modkey. - modkeys = self.held | self.ignored | set([modkey]) - for (key, value) in self.additions.items(): - if modkeys.issuperset(value): - self.held -= value - return key - - return modkey - - def key_ignored(self, key): '''Check if the given key is ignored by any ignore rules.''' @@ -104,9 +78,6 @@ class Keylet(object): if self.is_modcmd: l.append('modcmd=%r' % self.get_modcmd()) - elif self.held: - l.append('held=%r' % ''.join(sorted(self.held))) - if self.keycmd: l.append('keycmd=%r' % self.get_keycmd()) @@ -132,10 +103,7 @@ def add_modmap(uzbl, key, map): assert len(key) modmaps = uzbl.keylet.modmaps - if key[0] == "<" and key[-1] == ">": - key = key[1:-1] - - modmaps[key] = map + modmaps[key.strip('<>')] = map.strip('<>') uzbl.event("NEW_MODMAP", key, map) @@ -171,45 +139,6 @@ def add_key_ignore(uzbl, glob): uzbl.event('NEW_KEY_IGNORE', glob) -def add_modkey_addition(uzbl, modkeys, result): - '''Add a modkey addition definition. - - Examples: - set mod_addition = request MODKEY_ADDITION - @mod_addition <Shift> <Control> <Meta> - @mod_addition <Left> <Up> <Left-Up> - @mod_addition <Right> <Up> <Right-Up> - ... - - Then: - @bind <Right-Up> = <command1> - @bind <Meta>o = <command2> - ... - ''' - - additions = uzbl.keylet.additions - modkeys = set(modkeys) - - assert len(modkeys) and result and result not in modkeys - - for (existing_result, existing_modkeys) in additions.items(): - if existing_result != result: - assert modkeys != existing_modkeys - - additions[result] = modkeys - uzbl.event('NEW_MODKEY_ADDITION', modkeys, result) - - -def modkey_addition_parse(uzbl, modkeys): - '''Parse modkey addition definition.''' - - keys = filter(None, map(unicode.strip, modkeys.split(" "))) - keys = ['<%s>' % key.strip("<>") for key in keys if key.strip("<>")] - - assert len(keys) > 1 - add_modkey_addition(uzbl, keys[:-1], keys[-1]) - - def clear_keycmd(uzbl, *args): '''Clear the keycmd for this uzbl instance.''' @@ -220,15 +149,12 @@ def clear_keycmd(uzbl, *args): uzbl.event('KEYCMD_CLEARED') -def clear_modcmd(uzbl, clear_held=False): +def clear_modcmd(uzbl): '''Clear the modcmd for this uzbl instance.''' k = uzbl.keylet k.modcmd = '' k.is_modcmd = False - if clear_held: - k.ignored = set() - k.held = set() del uzbl.config['modcmd'] uzbl.event('MODCMD_CLEARED') @@ -244,28 +170,22 @@ def clear_current(uzbl): clear_keycmd(uzbl) -def focus_changed(uzbl, *args): - '''Focus to the uzbl instance has now been lost which means all currently - held keys in the held list will not get a KEY_RELEASE event so clear the - entire held list.''' - - clear_modcmd(uzbl, clear_held=True) - - -def update_event(uzbl, k, execute=True): +def update_event(uzbl, modstate, k, execute=True): '''Raise keycmd & modcmd update events.''' - keycmd, modcmd = k.get_keycmd(), k.get_modcmd() + keycmd, modcmd = k.get_keycmd(), ''.join(modstate) + k.get_modcmd() if k.is_modcmd: - uzbl.event('MODCMD_UPDATE', k) + logger.debug('modcmd_update, %s' % modcmd) + uzbl.event('MODCMD_UPDATE', modstate, k) else: - uzbl.event('KEYCMD_UPDATE', k) + logger.debug('keycmd_update, %s' % keycmd) + uzbl.event('KEYCMD_UPDATE', modstate, k) if uzbl.config.get('modcmd_updates', '1') == '1': - new_modcmd = k.get_modcmd() - if not new_modcmd: + new_modcmd = ''.join(modstate) + k.get_modcmd() + if not new_modcmd or not k.is_modcmd: del uzbl.config['modcmd'] elif new_modcmd == modcmd: @@ -293,54 +213,38 @@ def inject_str(str, index, inj): return "%s%s%s" % (str[:index], inj, str[index:]) -def get_keylet_and_key(uzbl, key, add=True): - '''Return the keylet and apply any transformations to the key as defined - by the modmapping or modkey addition rules. Return None if the key is - ignored.''' - +def parse_key_event(uzbl, key): + ''' Build a set from the modstate part of the event, and pass all keys through modmap ''' keylet = uzbl.keylet - key = keylet.modmap_key(key) - if len(key) == 1: - return (keylet, key) - - modkey = "<%s>" % key.strip("<>") - - if keylet.key_ignored(modkey): - if add: - keylet.ignored.add(modkey) - - elif modkey in keylet.ignored: - keylet.ignored.remove(modkey) - modkey = keylet.find_addition(modkey) - - if keylet.key_ignored(modkey): - return (keylet, None) - - return (keylet, modkey) + modstate, key = splitquoted(key) + modstate = set(['<%s>' % keylet.modmap_key(k) for k in modstate.split('|') if k]) + + key = keylet.modmap_key(key) + return modstate, key def key_press(uzbl, key): '''Handle KEY_PRESS events. Things done by this function include: 1. Ignore all shift key presses (shift can be detected by capital chars) - 3. In non-modcmd mode: + 2. In non-modcmd mode: a. append char to keycmd - 4. If not in modcmd mode and a modkey was pressed set modcmd mode. - 5. If in modcmd mode the pressed key is added to the held keys list. - 6. Keycmd is updated and events raised if anything is changed.''' + 3. If not in modcmd mode and a modkey was pressed set modcmd mode. + 4. Keycmd is updated and events raised if anything is changed.''' - (k, key) = get_keylet_and_key(uzbl, key.strip()) - if not key: - return + k = uzbl.keylet + modstate, key = parse_key_event(uzbl, key) + k.is_modcmd = any(not k.key_ignored(m) for m in modstate) - if key.lower() == '<space>' and not k.held and k.keycmd: + logger.debug('key press modstate=%s' % str(modstate)) + if key.lower() == 'space' and not k.is_modcmd and k.keycmd: k.keycmd = inject_str(k.keycmd, k.cursor, ' ') k.cursor += 1 - elif not k.held and len(key) == 1: - + elif not k.is_modcmd and len(key) == 1: if uzbl.config.get('keycmd_events', '1') != '1': + # TODO, make a note on what's going on here k.keycmd = '' k.cursor = 0 del uzbl.config['keycmd'] @@ -349,33 +253,29 @@ def key_press(uzbl, key): k.keycmd = inject_str(k.keycmd, k.cursor, key) k.cursor += 1 - elif len(key) > 1: - k.is_modcmd = True - if key not in k.held: - k.held.add(key) + elif len(key) == 1: + k.modcmd += key else: - k.is_modcmd = True - k.modcmd += key + if not k.key_ignored('<%s>' % key): + modstate.add('<%s>' % key) + k.is_modcmd = True - update_event(uzbl, k) + update_event(uzbl, modstate, k) def key_release(uzbl, key): '''Respond to KEY_RELEASE event. Things done by this function include: - 1. Remove the key from the keylet held list. - 2. If in a mod-command then raise a MODCMD_EXEC. - 3. Check if any modkey is held, if so set modcmd mode. - 4. Update the keycmd uzbl variable if anything changed.''' - - (k, key) = get_keylet_and_key(uzbl, key.strip(), add=False) + 1. If in a mod-command then raise a MODCMD_EXEC. + 2. Update the keycmd uzbl variable if anything changed.''' + k = uzbl.keylet + modstate, key = parse_key_event(uzbl, key) - if key in k.held: + if len(key) > 1: if k.is_modcmd: - uzbl.event('MODCMD_EXEC', k) + uzbl.event('MODCMD_EXEC', modstate, k) - k.held.remove(key) clear_modcmd(uzbl) @@ -385,7 +285,7 @@ def set_keycmd(uzbl, keycmd): k = uzbl.keylet k.keycmd = keycmd k.cursor = len(keycmd) - update_event(uzbl, k, False) + update_event(uzbl, set(), k, False) def inject_keycmd(uzbl, keycmd): @@ -394,7 +294,7 @@ def inject_keycmd(uzbl, keycmd): k = uzbl.keylet k.keycmd = inject_str(k.keycmd, k.cursor, keycmd) k.cursor += len(keycmd) - update_event(uzbl, k, False) + update_event(uzbl, set(), k, False) def append_keycmd(uzbl, keycmd): @@ -403,23 +303,29 @@ def append_keycmd(uzbl, keycmd): k = uzbl.keylet k.keycmd += keycmd k.cursor = len(k.keycmd) - update_event(uzbl, k, False) + update_event(uzbl, set(), 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) - update_event(uzbl, k, False) + update_event(uzbl, set(), k, False) def keycmd_backspace(uzbl, *args): @@ -431,7 +337,7 @@ def keycmd_backspace(uzbl, *args): k.keycmd = k.keycmd[:k.cursor-1] + k.keycmd[k.cursor:] k.cursor -= 1 - update_event(uzbl, k, False) + update_event(uzbl, set(), k, False) def keycmd_delete(uzbl, *args): @@ -442,14 +348,14 @@ def keycmd_delete(uzbl, *args): return k.keycmd = k.keycmd[:k.cursor] + k.keycmd[k.cursor+1:] - update_event(uzbl, k, False) + update_event(uzbl, set(), k, False) def keycmd_exec_current(uzbl, *args): '''Raise a KEYCMD_EXEC with the current keylet and then clear the keycmd.''' - uzbl.event('KEYCMD_EXEC', uzbl.keylet) + uzbl.event('KEYCMD_EXEC', set(), uzbl.keylet) clear_keycmd(uzbl) @@ -476,7 +382,7 @@ def set_cursor_pos(uzbl, index): cursor = len(k.keycmd) k.cursor = cursor - update_event(uzbl, k, False) + update_event(uzbl, set(), k, False) # plugin init hook @@ -485,8 +391,6 @@ def init(uzbl): connect_dict(uzbl, { 'APPEND_KEYCMD': append_keycmd, - 'FOCUS_GAINED': focus_changed, - 'FOCUS_LOST': focus_changed, 'IGNORE_KEY': add_key_ignore, 'INJECT_KEYCMD': inject_keycmd, 'KEYCMD_BACKSPACE': keycmd_backspace, @@ -496,7 +400,8 @@ def init(uzbl): 'KEYCMD_CLEAR': clear_keycmd, 'KEY_PRESS': key_press, 'KEY_RELEASE': key_release, - 'MODKEY_ADDITION': modkey_addition_parse, + 'MOD_PRESS': key_press, + 'MOD_RELEASE': key_release, 'MODMAP': modmap_parse, 'SET_CURSOR_POS': set_cursor_pos, 'SET_KEYCMD': set_keycmd, @@ -504,7 +409,6 @@ def init(uzbl): export_dict(uzbl, { 'add_key_ignore': add_key_ignore, - 'add_modkey_addition': add_modkey_addition, 'add_modmap': add_modmap, 'append_keycmd': append_keycmd, 'clear_current': clear_current, 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/follow.js b/examples/data/scripts/follow.js index b7b0d82..5ecdcef 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -16,7 +16,16 @@ uzbldivid = 'uzbl_link_hints'; uzbl.follow = function() { // Export charset = arguments[0]; - newwindow = arguments[2]; + if (arguments[2] == 0 || arguments[2] == 'click') { + newwindow = false; + returnuri = false; + } else if (arguments[2] == 1 || arguments[2] == 'newwindow') { + newwindow = true; + returnuri = false; + } else if (arguments[2] == 'returnuri') { + newwindow = false; + returnuri = true; + } var keypress = arguments[1]; return arguments.callee.followLinks(keypress); @@ -126,19 +135,19 @@ uzbl.follow.generateHint = function(doc, el, label, top, left) { // but at least set the href of the link. (needs some improvements) uzbl.follow.clickElem = function(item) { if(!item) return; - var name = item.tagName; - if (name == 'INPUT') { - var type = item.getAttribute('type').toUpperCase(); - if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') { + if (item instanceof HTMLInputElement) { + var type = item.type; + if (type == 'text' || type == 'file' || type == 'password') { item.focus(); item.select(); return "XXXEMIT_FORM_ACTIVEXXX"; } // otherwise fall through to a simulated mouseclick. - } else if (name == 'TEXTAREA' || name == 'SELECT') { + } else if (item instanceof HTMLTextAreaElement || item instanceof HTMLSelectElement) { item.focus(); - item.select(); + if(typeof item.select != 'undefined') + item.select(); return "XXXEMIT_FORM_ACTIVEXXX"; } @@ -169,9 +178,13 @@ uzbl.follow.reDrawHints = function(elems, chars) { elements.forEach(function(el, i) { var label = labels[i]; var pos = positions[i]; - var doc = uzbl.follow.getDocument(el); - var h = uzbl.follow.generateHint(doc, el, label, pos[0], pos[1]); - doc.hintdiv.appendChild(h); + try { + var doc = uzbl.follow.getDocument(el); + var h = uzbl.follow.generateHint(doc, el, label, pos[0], pos[1]); + doc.hintdiv.appendChild(h); + } catch (err) { + // Unable to attach label -> shrug it off and continue + } }); } @@ -222,7 +235,7 @@ uzbl.follow.followLinks = function(follow) { //var desc = '*[title], img[alt], applet[alt], area[alt], input[alt]'; //var image = 'img, input[type=image]'; - if(newwindow) + if(newwindow || returnuri) var res = this.query(uri); else var res = this.query(followable); @@ -237,6 +250,11 @@ uzbl.follow.followLinks = function(follow) { // clear all of our hints this.clearHints(); + if (returnuri) { + var uri = el.src || el.href; + return "XXXRETURNED_URIXXX" + uri + } + if (newwindow) { // we're opening a new window using the URL attached to this element var uri = el.src || el.href; diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh index 014793e..30d3775 100755 --- a/examples/data/scripts/follow.sh +++ b/examples/data/scripts/follow.sh @@ -1,13 +1,31 @@ #!/bin/sh # This scripts acts on the return value of followLinks in follow.js -case "$1" in +result=$1 +shift + +uriaction=$1 +shift + +case "$result" in XXXEMIT_FORM_ACTIVEXXX) # a form element was selected - printf 'event FORM_ACTIVE\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" + printf 'event KEYCMD_CLEAR\n' > "$UZBL_FIFO" ;; XXXRESET_MODEXXX) # a link was selected, reset uzbl's input mode printf 'set mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" ;; + XXXRETURNED_URIXXX*) + uri=${result#XXXRETURNED_URIXXX} + + case "$uriaction" in + set) + printf 'uri '"$uri"'\n' | sed -e 's/@/\\@/' > "$UZBL_FIFO" + ;; + clipboard) + printf "$uri" | xclip + ;; + esac + printf 'set mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" esac diff --git a/examples/data/scripts/formfiller.js b/examples/data/scripts/formfiller.js index abf0162..a5fc9ee 100644 --- a/examples/data/scripts/formfiller.js +++ b/examples/data/scripts/formfiller.js @@ -1,24 +1,37 @@ uzbl.formfiller = { + inputTypeIsText: function(type) { + var types = [ 'text', 'password', 'search', 'email', 'url', + 'number', 'range', 'color', 'date', 'month', + 'week', 'time', 'datetime', 'datetime-local' ]; + + for(var i = 0; i < types.length; ++i) + if(types[i] == type) return true; + + return false; + } + + , + dump: function() { var rv = ''; var allFrames = new Array(window); - for ( f=0; f<window.frames.length; ++f ) { + + for ( var f = 0; f < window.frames.length; ++f ) { allFrames.push(window.frames[f]); } - for ( j=0; j<allFrames.length; ++j ) { + + for ( var j = 0; j < allFrames.length; ++j ) { try { var xp_res = allFrames[j].document.evaluate( '//input', allFrames[j].document.documentElement, null, XPathResult.ANY_TYPE,null ); var input; while ( input = xp_res.iterateNext() ) { - var type = (input.type?input.type:text); - if ( type == 'text' || type == 'password' || type == 'search' ) { - rv += '%' + escape(input.name) + '(' + type + '):' + input.value + '\n'; - } - else if ( type == 'checkbox' || type == 'radio' ) { - rv += '%' + escape(input.name) + '(' + type + '){' + escape(input.value) + '}:' + (input.checked?'1':'0') + '\n'; + if ( inputTypeIsText(input.type) ) { + rv += '%' + escape(input.name) + '(' + input.type + '):' + input.value + '\n'; + } else if ( input.type == 'checkbox' || input.type == 'radio' ) { + rv += '%' + escape(input.name) + '(' + input.type + '){' + escape(input.value) + '}:' + (input.checked?'1':'0') + '\n'; } } xp_res = allFrames[j].document.evaluate( @@ -39,12 +52,12 @@ uzbl.formfiller = { insert: function(fname, ftype, fvalue, fchecked) { fname = unescape(fname); var allFrames = new Array(window); - for ( f=0; f<window.frames.length; ++f ) { + for ( var f = 0; f < window.frames.length; ++f ) { allFrames.push(window.frames[f]); } - for ( j=0; j<allFrames.length; ++j ) { + for ( var j = 0; j < allFrames.length; ++j ) { try { - if ( ftype == 'text' || ftype == 'password' || ftype == 'search' || ftype == 'textarea' ) { + if ( uzbl.formfiller.inputTypeIsText(ftype) || ftype == 'textarea' ) { allFrames[j].document.getElementsByName(fname)[0].value = fvalue; } else if ( ftype == 'checkbox' ) { diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 3dc9dc4..394bfbd 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -39,7 +39,10 @@ GenForm () GetOption () { DMENU_SCHEME=formfiller - DMENU_PROMPT="choose profile" + + # util/dmenu.sh doesn't handle spaces in DMENU_PROMPT. a proper fix will be + # tricky. + DMENU_PROMPT="choose_profile" DMENU_LINES=4 . "$UZBL_UTIL_DIR/dmenu.sh" @@ -66,27 +69,28 @@ ParseFields () field = $0 sub ( /[^:]*:/, "", field ) - 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)/ ) + 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 ) } + else + printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",0);\n", + parts[1], parts[2], field ) + + }' } @@ -116,7 +120,7 @@ Load () ParseProfile $option < "$file" \ | ParseFields \ - | sed 's/@/\\@/' \ + | sed 's/@/\\@/g' \ > "$UZBL_FIFO" } @@ -132,7 +136,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..76a7055 100644 --- a/examples/data/scripts/util/uzbl-dir.sh +++ b/examples/data/scripts/util/uzbl-dir.sh @@ -9,11 +9,12 @@ UZBL_SOCKET_DIR=/tmp # Directories UZBL_DOWNLOAD_DIR="${XDG_DOWNLOAD_DIR:-$HOME}" -UZBL_FORMS_DIR="$UZBL_DATA_DIR/dforms" +UZBL_FORMS_DIR="${UZBL_FORMS_DIR:-$UZBL_DATA_DIR/dforms}" # Data files -UZBL_CONFIG_FILE="$UZBL_CONFIG_DIR/config" -UZBL_COOKIE_FILE="$UZBL_DATA_DIR/cookies.txt" -UZBL_BOOKMARKS_FILE="$UZBL_DATA_DIR/bookmarks" -UZBL_HISTORY_FILE="$UZBL_DATA_DIR/history" -UZBL_SESSION_FILE="$UZBL_DATA_DIR/browser-session" +UZBL_CONFIG_FILE="${UZBL_CONFIG_FILE:-$UZBL_CONFIG_DIR/config}" +UZBL_COOKIE_FILE="${UZBL_COOKIE_FILE:-$UZBL_DATA_DIR/cookies.txt}" +UZBL_BOOKMARKS_FILE="${UZBL_BOOKMARKS_FILE:-$UZBL_DATA_DIR/bookmarks}" +UZBL_TEMPS_FILE="${UZBL_TEMPS_FILE:-$UZBL_DATA_DIR/temps}" +UZBL_HISTORY_FILE="${UZBL_HISTORY_FILE:-$UZBL_DATA_DIR/history}" +UZBL_SESSION_FILE="${UZBL_SESSION_FILE:-$UZBL_DATA_DIR/browser-session}" |