User Tools

Site Tools


per-instance-history

Per instance history menu

Description

This script will display a history menu overlaying only the uzbl instance being spawned from. You can still use all history entries, i.e. it doesn't matter which uzbl instance wrote a specific history entry.
Think of it as a way to emulate the url/history bars in traditional browsers.

Requirements

  • dmenu-vertical

Installation

Copy the history script to a suitable place and create a binding that spawns the history script from uzbl:

@bind U = spawn /path/to/pi_history.sh

Use the default history handler script:

@on_event   LOAD_FINISH    spawn @scripts_dir/history.sh

Set fifo_dir to a path of your liking:

set fifo_dir = /tmp

You can supply these commands to uzbl using either one of the provided interfaces.

Script

#!/bin/bash
history_file=/tmp/uzbl.history
 
xy=$(xwininfo -id $3 | \
     sed -ne 's/Corners:[ ]*[+-]\([0-9]*\)[+-]\([0-9]*\).*$/\1 \2/p')
w=$(xwininfo -id $3 | \
     sed -ne 's/-geometry[ ]*\([0-9]*\)x.*$/\1/p')
x=${xy% *}; y=${xy##* }
 
 
goto=$(tac $history_file | dmenu-vertical -i -xs -rs -l 10 \
                           -fn '-*-profont-*-*-*-*-11-*-*-*-*-*-*-*' \
                           -nf grey50 -nb black -sb '#494b4f' -sf 'orange' \
                           -x $x -y $y -w $w -p '>>:'|  cut -d ' ' -f -3 | awk '{print $NF}')
 
[ -n "$goto" ] && echo "set uri = $goto" > $4

Alternative

www.linuxized.com_wp-content_uploads_2009_12_uzbl-history-smart-xft.jpg

This version draws dmenu at the bottom of the window and includes bookmarks in the search. Also passing “u” as a parameter filters out duplicate entries and will sort urls based on length.

@bind U = spawn /path/to/pi_history.sh u
#!/bin/bash
history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history
bookmarks_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
 
xy=$(xwininfo -id $3 | \
     sed -ne 's/Corners:[ ]*[+-]\([0-9]*\)[+-]\([0-9]*\).*$/\1 \2/p')
wh=$(xwininfo -id $3 | \
     sed -ne 's/-geometry[ ]*\([0-9]*\)x\([0-9]*\).*$/\1 \2/p')
x=${xy% *}; y=${xy##* }
x=$((x + 1))
w=${wh% *}; h=${wh##* }
y=$((y + h - 215)) 
 
if [[ $8 == "u" ]]; then
	goto=$(cat $history_file | cut -d ' ' -f3- | cat $bookmarks_file - | sort -u | awk '{ print length($1), $0 | "sort -n" }' | dmenu -i -xs -rs -l 10 \
                           -fn '-*-profont-*-*-*-*-11-*-*-*-*-*-*-*' \
                           -nf grey50 -nb black -sb '#494b4f' -sf 'orange' \
                           -x $x -y $y -w $w -p '>>:'| cut -d ' ' -f2)
else
	goto=$(tac $history_file $bookmarks_file | dmenu -i -xs -rs -l 10 \
                           -fn '-*-profont-*-*-*-*-11-*-*-*-*-*-*-*' \
                           -nf grey50 -nb black -sb '#494b4f' -sf 'orange' \
                           -x $x -y $y -w $w -p '>>:'| cut -d ' ' -f -3 | awk '{print $NF}')
fi
 
 
[ -n "$goto" ] && echo "set uri = $goto" > $4

if you have dmenu patched with xft and visit non-english sites, you'll appreciate this version more:

#!/bin/bash
history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history
bookmarks_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
 
xy=$(xwininfo -id $3 | \
     sed -ne 's/Corners:[ ]*[+-]\([0-9]*\)[+-]\([0-9]*\).*$/\1 \2/p')
wh=$(xwininfo -id $3 | \
     sed -ne 's/-geometry[ ]*\([0-9]*\)x\([0-9]*\).*$/\1 \2/p')
x=${xy% *}; y=${xy##* }
x=$((x + 1))
w=${wh% *}; h=${wh##* }
y=$((y + h - 215)) 
 
if [[ $8 == "u" ]]; then
	goto=$(cat $history_file | cut -d ' ' -f3- | cat $bookmarks_file - | sort -u | awk '{ print length($1), $0 | "sort -n" }' | dmenu -i -xs -rs -l 10 \
                           -fn 'xft:dejavusansmono-8' \
                           -nf grey80 -nb black -sb '#494b4f' -sf 'orange' \
                           -x $x -y $y -w $w -p '>>:'| cut -d ' ' -f2)
else
	goto=$(tac $history_file $bookmarks_file | dmenu -i -xs -rs -l 10 \
                           -fn 'xft:dejavusansmono-8' \
                           -nf grey80 -nb black -sb '#494b4f' -sf 'orange' \
                           -x $x -y $y -w $w -p '>>:'| cut -d ' ' -f -3 | awk '{print $NF}')
fi
 
[ -n "$goto" ] && echo "set uri = $goto" > $4
per-instance-history.txt · Last modified: 2016/08/31 14:10 (external edit)