From 32aabff645692e78e2ef2c438d11ce2fafac9b91 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 09:52:44 -0400 Subject: Reorder Bnd style to match others --- examples/config/config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/config/config b/examples/config/config index b6d9fe3..81aa464 100644 --- a/examples/config/config +++ b/examples/config/config @@ -353,13 +353,13 @@ set stack = @mode_config stack @insert modcmd_updates = 0 # Multi-stage-binding mode config. -@stack keycmd_events = 1 -@stack modcmd_updates = 1 -@stack forward_keys = 0 @stack keycmd_style = foreground="red" -@stack prompt_style = foreground="#888" weight="light" @stack status_background = #202020 @stack mode_indicator = Bnd +@stack prompt_style = foreground="#888" weight="light" +@stack keycmd_events = 1 +@stack modcmd_updates = 1 +@stack forward_keys = 0 set default_mode = command -- cgit v1.2.3 From b9cc0b3e0a9ed7f5ce1181e94cf813544011547e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 10:07:26 -0400 Subject: Put `then' on the same line as `if' --- examples/data/scripts/download.sh | 3 +-- examples/data/scripts/formfiller.sh | 21 +++++++-------------- examples/data/scripts/instance-select-wmii.sh | 21 +++++++-------------- examples/data/scripts/load_url_from_bookmarks.sh | 3 +-- examples/data/scripts/load_url_from_history.sh | 3 +-- 5 files changed, 17 insertions(+), 34 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh index f6d34e9..0f051db 100755 --- a/examples/data/scripts/download.sh +++ b/examples/data/scripts/download.sh @@ -14,8 +14,7 @@ export http_proxy test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; } # only changes the dir for the $get sub process -if echo "$url" | grep -E '.*\.torrent' >/dev/null; -then +if echo "$url" | grep -E '.*\.torrent' >/dev/null; then ( cd "$dest"; $GET "$url") else ( cd "$dest"; $GET "$url") diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 69eca17..2801262 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -43,8 +43,7 @@ NF="#4e7093" SB="#003d7c" SF="#3a9bff" -if [ "`dmenu --help 2>&1| grep lines`x" != "x" ] -then +if [ "`dmenu --help 2>&1| grep lines`x" != "x" ]; then LINES=" -l 3 " else LINES="" @@ -87,12 +86,10 @@ action=$1 domain=$(echo $url | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/') -if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$action" != 'add' -a "$action" != 'once' ] -then +if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$action" != 'add' -a "$action" != 'once' ]; then action="new" [ -e "$keydir/$domain" ] && action="load" -elif [ "$action" = 'edit' ] && [ ! -e "$keydir/$domain" ] -then +elif [ "$action" = 'edit' ] && [ ! -e "$keydir/$domain" ]; then action="new" fi @@ -152,11 +149,9 @@ insertFunction="function insert(fname, ftype, fvalue, fchecked) { \ } \ }; " -if [ "$action" = 'load' ] -then +if [ "$action" = 'load' ]; then [ -e $keydir/$domain ] || exit 2 - if [ `cat $keydir/$domain|grep "!profile"|wc -l` -gt 1 ] - then + if [ `cat $keydir/$domain|grep "!profile"|wc -l` -gt 1 ]; then menu=`cat $keydir/$domain| \ sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p'` option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` @@ -179,8 +174,7 @@ then printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo -elif [ "$action" = "once" ] -then +elif [ "$action" = "once" ]; then tmpfile=`mktemp` printf 'js %s dump(); \n' "$dumpFunction" | \ socat - unix-connect:$socket | \ @@ -207,8 +201,7 @@ then sed -e 's/@/\\@/g' > $fifo rm -f $tmpfile else - if [ "$action" = 'new' -o "$action" = 'add' ] - then + if [ "$action" = 'new' -o "$action" = 'add' ]; then [ "$action" = 'new' ] && echo "$MODELINE" > $keydir/$domain echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain # diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh index fdd27e6..1340351 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -13,39 +13,32 @@ COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" -if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]' -then +if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then DMENU="dmenu -i -xs -rs -l 10" # vertical patch else DMENU="dmenu -i" fi -if [ "$1" == 'list' ] -then +if [ "$1" == 'list' ]; then list= # get window id's of uzbl clients. we could also get the label in one shot but it's pretty tricky - for i in $(wmiir read /tag/sel/index | grep uzbl |cut -d ' ' -f2) - do + for i in $(wmiir read /tag/sel/index | grep uzbl |cut -d ' ' -f2); do label=$(wmiir read /client/$i/label) list="$list$i : $label\n" done window=$(echo -e "$list" | $DMENU $COLORS | cut -d ' ' -f1) wmiir xwrite /tag/sel/ctl "select client $window" -elif [ "$1" == 'next' ] -then +elif [ "$1" == 'next' ]; then current=$(wmiir read /client/sel/ctl | head -n 1) # find the next uzbl window and focus it next=$(wmiir read /tag/sel/index | grep -A 10000 " $current " | grep -m 1 uzbl | cut -d ' ' -f2) - if [ x"$next" != "x" ] - then + if [ x"$next" != "x" ]; then wmiir xwrite /tag/sel/ctl "select client $next" fi -elif [ "$1" == 'prev' ] -then +elif [ "$1" == 'prev' ]; then current=$(wmiir read /client/sel/ctl | head -n 1) prev=$(wmiir read /tag/sel/index | grep -B 10000 " $current " | tac | grep -m 1 uzbl | cut -d ' ' -f2) - if [ x"$prev" != "x" ] - then + if [ x"$prev" != "x" ]; then wmiir xwrite /tag/sel/ctl "select client $prev" fi else diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 1e9f9e7..569f2bf 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -5,8 +5,7 @@ file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks [ -r "$file" ] || exit COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" -if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]' -then +if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then DMENU="dmenu -i -xs -rs -l 10" # vertical patch # show tags as well goto=`$DMENU $COLORS < $file | awk '{print $1}'` diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index 62e02ac..bec6258 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -6,8 +6,7 @@ history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history # choose from all entries, sorted and uniqued # goto=`awk '{print $3}' $history_file | sort -u | dmenu -i` COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" -if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; -then +if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then DMENU="dmenu -i -xs -rs -l 10" # vertical patch # choose an item in reverse order, showing also the date and page titles # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url. -- cgit v1.2.3 From 1c8635db3838f613e400a5ef8897f7853e260276 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 10:09:09 -0400 Subject: Use $() over `` --- examples/data/scripts/formfiller.sh | 22 +++++++++++----------- examples/data/scripts/history.sh | 4 ++-- examples/data/scripts/insert_bookmark.sh | 4 ++-- examples/data/scripts/load_url_from_bookmarks.sh | 4 ++-- examples/data/scripts/load_url_from_history.sh | 10 +++++----- examples/data/scripts/session.sh | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 2801262..564bf82 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -43,7 +43,7 @@ NF="#4e7093" SB="#003d7c" SF="#3a9bff" -if [ "`dmenu --help 2>&1| grep lines`x" != "x" ]; then +if [ "$(dmenu --help 2>&1 | grep lines)x" != "x" ]; then LINES=" -l 3 " else LINES="" @@ -54,7 +54,7 @@ MODELINE="> vim:ft=formfiller" keydir=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/dforms -[ -d "`dirname $keydir`" ] || exit 1 +[ -d "$(dirname $keydir)" ] || exit 1 [ -d "$keydir" ] || mkdir "$keydir" editor="${VISUAL}" @@ -151,23 +151,23 @@ insertFunction="function insert(fname, ftype, fvalue, fchecked) { \ if [ "$action" = 'load' ]; then [ -e $keydir/$domain ] || exit 2 - if [ `cat $keydir/$domain|grep "!profile"|wc -l` -gt 1 ]; then - menu=`cat $keydir/$domain| \ - sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p'` - option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` + if [ $(cat $keydir/$domain | grep "!profile" | wc -l) -gt 1 ]; then + menu=$(cat $keydir/$domain | \ + sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p') + option=$(echo -e -n "$menu" | dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}") fi # Remove comments sed '/^>/d' -i $tmpfile sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $keydir/$domain - fields=`cat $keydir/$domain | \ + fields=$(cat $keydir/$domain | \ sed -n "/^!profile=${option}/,/^!profile=/p" | \ sed '/^!profile=/d' | \ sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \ sed 's/^\(.\+\)$/<{br}>\1/' | \ tr -d '\n' | \ - sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g'` + sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g') printf '%s\n' "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo @@ -175,7 +175,7 @@ if [ "$action" = 'load' ]; then sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo elif [ "$action" = "once" ]; then - tmpfile=`mktemp` + tmpfile=$(mktemp) printf 'js %s dump(); \n' "$dumpFunction" | \ socat - unix-connect:$socket | \ sed -n '/^[^(]\+([^)]\+):/p' > $tmpfile @@ -188,11 +188,11 @@ elif [ "$action" = "once" ]; then sed '/^>/d' -i $tmpfile sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $tmpfile - fields=`cat $tmpfile | \ + fields=$(cat $tmpfile | \ sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \ sed 's/^\(.\+\)$/<{br}>\1/' | \ tr -d '\n' | \ - sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g'` + sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g') printf '%s\n' "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo diff --git a/examples/data/scripts/history.sh b/examples/data/scripts/history.sh index 7c83aa6..be5fd34 100755 --- a/examples/data/scripts/history.sh +++ b/examples/data/scripts/history.sh @@ -1,5 +1,5 @@ #!/bin/sh file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history -[ -d `dirname $file` ] || exit 1 -echo `date +'%Y-%m-%d %H:%M:%S'`" $6 $7" >> $file +[ -d $(dirname $file) ] || exit 1 +echo $(date +'%Y-%m-%d %H:%M:%S')" $6 $7" >> $file diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh index d0ec84e..4d29ad6 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -7,10 +7,10 @@ which zenity &>/dev/null || exit 2 url=$6 # replace tabs, they are pointless in titles and we want to use tabs as delimiter. title=$(echo "$7" | sed 's/\t/ /') -entry=`zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$url $title\t"` +entry=$(zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$url $title\t") exitstatus=$? if [ $exitstatus -ne 0 ]; then exit $exitstatus; fi -url=`echo $entry | awk '{print $1}'` +url=$(echo $entry | awk '{print $1}') # TODO: check if already exists, if so, and tags are different: ask if you want to replace tags echo "$entry" >/dev/null #for some reason we need this.. don't ask me why diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 569f2bf..3134407 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -8,11 +8,11 @@ COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then DMENU="dmenu -i -xs -rs -l 10" # vertical patch # show tags as well - goto=`$DMENU $COLORS < $file | awk '{print $1}'` + goto=$($DMENU $COLORS < $file | awk '{print $1}') else DMENU="dmenu -i" # because they are all after each other, just show the url, not their tags. - goto=`awk '{print $1}' $file | $DMENU $COLORS` + goto=$(awk '{print $1}' $file | $DMENU $COLORS) fi #[ -n "$goto" ] && echo "uri $goto" > $4 diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index bec6258..5156eee 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -4,19 +4,19 @@ history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history [ -r "$history_file" ] || exit 1 # choose from all entries, sorted and uniqued -# goto=`awk '{print $3}' $history_file | sort -u | dmenu -i` +# goto=$(awk '{print $3}' $history_file | sort -u | dmenu -i) COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then DMENU="dmenu -i -xs -rs -l 10" # vertical patch # choose an item in reverse order, showing also the date and page titles # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url. - goto=`tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}'` + goto=$(tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}') else DMENU="dmenu -i" # choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order - current=`tail -n 1 $history_file | awk '{print $3}'`; - goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" \ - | sort -u) | $DMENU $COLORS` + current=$(tail -n 1 $history_file | awk '{print $3}'); + goto=$((echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" \ + | sort -u) | $DMENU $COLORS) fi [ -n "$goto" ] && echo "uri $goto" > $4 diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index 1059b5e..acd6934 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -26,7 +26,7 @@ fi case $act in "launch" ) - urls=`cat $sessionfile` + urls=$(cat $sessionfile) if [ "$urls." = "." ]; then $UZBL else -- cgit v1.2.3 From aef2bd5944ea23b9bf3ec58460e13f22f792dd44 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:12:56 -0400 Subject: Factor out dmenu functionality --- examples/data/scripts/util/dmenu.sh | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 examples/data/scripts/util/dmenu.sh (limited to 'examples') diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh new file mode 100644 index 0000000..3f307f2 --- /dev/null +++ b/examples/data/scripts/util/dmenu.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# dmenu setup + +case "$DMENU_SCHEME" in + # wmii + "wmii" ) + NB="#303030" + NF="khaki" + SB="#ccffaa" + SF="#303030" + ;; + # Formfiller + "formfiller" ) + NB="#0f0f0f" + NF="4e7093" + SB="#003d7c" + SF="#3a9bff" + ;; + # Bookmarks + "bookmarks" ) + NB="#303030" + NF="khaki" + SB="#ccffaa" + SF="#303030" + ;; + # History + "history" ) + NB="#303030" + NF="khaki" + SB="#ccffaa" + SF="#303030" + ;; + # Default + * ) + NB="#303030" + NF="khaki" + SB="#ccffaa" + SF="#303030" + ;; +esac + +# Default arguments +if [ "x$DMENU_ARGS" = "x" ]; then + DMENU_ARGS="-i" +fi + +# Set the prompt if wanted +if [ ! "x$DMENU_PROMPT" = "x" ]; then + DMENU_ARGS="$DMENU_ARGS -p $DMENU_PROMPT" +fi + +# Detect the xmms patch +if dmenu --help 2>&1 | grep -q '\[-xs\]'; then + DMENU_ARGS="$DMENU_ARGS -xs" + DMENU_HAS_XMMS=1 +fi + +# Detect the vertical patch +if dmenu --help 2>&1 | grep -q '\[-l lines\]'; then + # Default to 10 lines + if [ "x$DMENU_LINES" = "x" ]; then + DMENU_LINES=10 + fi + + DMENU_ARGS="$DMENU_ARGS -l $DMENU_LINES" + DMENU_HAS_VERTICAL=1 + + # Detect the resize patch + if dmenu --help 2>&1 | grep -q '\[-rs\]'; then + DMENU_ARGS="$DMENU_ARGS -rs" + fi +fi + +DMENU="dmenu $DMENU_ARGS -nb $NB -nf $NF -sb $SB -sf $SF" -- cgit v1.2.3 From 8526a0dd73661ae0a5d1cf950ea5e5f63b5b08c5 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:13:17 -0400 Subject: Add uzbl directory and file discovery --- examples/data/scripts/util/uzbl-dir.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/data/scripts/util/uzbl-dir.sh (limited to 'examples') diff --git a/examples/data/scripts/util/uzbl-dir.sh b/examples/data/scripts/util/uzbl-dir.sh new file mode 100644 index 0000000..01fb469 --- /dev/null +++ b/examples/data/scripts/util/uzbl-dir.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Common directories and files used in scripts + +# Common things first +UZBL_DATA_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl +UZBL_CONFIG_DIR=${XDG_CONFIG_DIR:-$HOME/.config}/uzbl +UZBL_FIFO_DIR=/tmp + +# Directories +UZBL_DOWNLOAD_DIR=${XDG_DOWNLOAD_DIR:-$HOME} +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 -- cgit v1.2.3 From 6229a4eff9a4e9ac38c790d37ac05fd2ea0a6a7b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:11:13 -0400 Subject: Add editor utility script --- examples/data/scripts/util/editor.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/data/scripts/util/editor.sh (limited to 'examples') diff --git a/examples/data/scripts/util/editor.sh b/examples/data/scripts/util/editor.sh new file mode 100644 index 0000000..a152ebd --- /dev/null +++ b/examples/data/scripts/util/editor.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Editor selection + +if [ "x$VTERM" = "x" ]; then + VTERM="xterm" +fi + +UZBL_EDITOR="$VISUAL" +if [ -z "$UZBL_EDITOR" ]; then + if [ -z "$EDITOR" ]; then + UZBL_EDITOR="$VTERM -e vim" + else + UZBL_EDITOR="$VTERM -e $EDITOR" + fi +fi -- cgit v1.2.3 From ea9290192f06b61a88538d6f646fec3aa7d405ce Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:11:30 -0400 Subject: Add script to manage common uzbl arguments --- examples/data/scripts/util/uzbl-args.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/data/scripts/util/uzbl-args.sh (limited to 'examples') diff --git a/examples/data/scripts/util/uzbl-args.sh b/examples/data/scripts/util/uzbl-args.sh new file mode 100644 index 0000000..7a3dbe5 --- /dev/null +++ b/examples/data/scripts/util/uzbl-args.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Arguments from uzbl + +UZBL_CONFIG=$1 +shift +UZBL_PID=$1 +shift +UZBL_XID=$1 +shift +UZBL_FIFO=$1 +shift +UZBL_SOCKET=$1 +shift +UZBL_URL=$1 +shift +UZBL_TITLE=$1 +shift -- cgit v1.2.3 From c4f026cb42b016193007d90447e6ccb9438c818a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:13:52 -0400 Subject: PEP8 auth.py --- examples/data/scripts/auth.py | 68 +++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/auth.py b/examples/data/scripts/auth.py index 4feb90b..9c1b4fc 100755 --- a/examples/data/scripts/auth.py +++ b/examples/data/scripts/auth.py @@ -4,50 +4,50 @@ import gtk import sys def responseToDialog(entry, dialog, response): - dialog.response(response) + dialog.response(response) def getText(authInfo, authHost, authRealm): - dialog = gtk.MessageDialog( - None, - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - gtk.MESSAGE_QUESTION, - gtk.BUTTONS_OK_CANCEL, - None) - dialog.set_markup('%s at %s' % (authRealm, authHost)) + dialog = gtk.MessageDialog( + None, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, + gtk.MESSAGE_QUESTION, + gtk.BUTTONS_OK_CANCEL, + None) + dialog.set_markup('%s at %s' % (authRealm, authHost)) - login = gtk.Entry() - password = gtk.Entry() - password.set_visibility(False) + login = gtk.Entry() + password = gtk.Entry() + password.set_visibility(False) - login.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK) - password.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK) + login.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK) + password.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK) - hbox = gtk.HBox(); + hbox = gtk.HBox(); - vbox_entries = gtk.VBox(); - vbox_labels = gtk.VBox(); + vbox_entries = gtk.VBox(); + vbox_labels = gtk.VBox(); - vbox_labels.pack_start(gtk.Label("Login:"), False, 5, 5) - vbox_labels.pack_end(gtk.Label("Password:"), False, 5, 5) + vbox_labels.pack_start(gtk.Label("Login:"), False, 5, 5) + vbox_labels.pack_end(gtk.Label("Password:"), False, 5, 5) - vbox_entries.pack_start(login) - vbox_entries.pack_end(password) + vbox_entries.pack_start(login) + vbox_entries.pack_end(password) - dialog.format_secondary_markup("Please enter username and password:") - hbox.pack_start(vbox_labels, True, True, 0) - hbox.pack_end(vbox_entries, True, True, 0) + dialog.format_secondary_markup("Please enter username and password:") + hbox.pack_start(vbox_labels, True, True, 0) + hbox.pack_end(vbox_entries, True, True, 0) - dialog.vbox.pack_start(hbox) - dialog.show_all() - rv = dialog.run() + dialog.vbox.pack_start(hbox) + dialog.show_all() + rv = dialog.run() - output = login.get_text() + "\n" + password.get_text() - dialog.destroy() - return rv, output + output = login.get_text() + "\n" + password.get_text() + dialog.destroy() + return rv, output if __name__ == '__main__': - rv, output = getText(sys.argv[8], sys.argv[9], sys.argv[10]) - if (rv == gtk.RESPONSE_OK): - print output; - else: - exit(1) + rv, output = getText(sys.argv[8], sys.argv[9], sys.argv[10]) + if (rv == gtk.RESPONSE_OK): + print output; + else: + exit(1) -- cgit v1.2.3 From f1e85d8f962510a667e765b48c979773bb5ea459 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:14:08 -0400 Subject: Make indentation in follow.js uniform --- examples/data/scripts/follow.js | 48 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index a42447c..bcceb74 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -193,38 +193,38 @@ function reDrawHints(elems, chars) { // pass: number of keys // returns: key length function labelLength(n) { - var oldn = n; - var keylen = 0; - if(n < 2) { - return 1; - } - n -= 1; // our highest key will be n-1 - while(n) { - keylen += 1; - n = Math.floor(n / charset.length); - } - return keylen; + var oldn = n; + var keylen = 0; + if(n < 2) { + return 1; + } + n -= 1; // our highest key will be n-1 + while(n) { + keylen += 1; + n = Math.floor(n / charset.length); + } + return keylen; } // pass: number // returns: label function intToLabel(n) { - var label = ''; - do { - label = charset.charAt(n % charset.length) + label; - n = Math.floor(n / charset.length); - } while(n); - return label; + var label = ''; + do { + label = charset.charAt(n % charset.length) + label; + n = Math.floor(n / charset.length); + } while(n); + return label; } // pass: label // returns: number function labelToInt(label) { - var n = 0; - var i; - for(i = 0; i < label.length; ++i) { - n *= charset.length; - n += charset.indexOf(label[i]); - } - return n; + var n = 0; + var i; + for(i = 0; i < label.length; ++i) { + n *= charset.length; + n += charset.indexOf(label[i]); + } + return n; } //Put it all together function followLinks(follow) { -- cgit v1.2.3 From 6c53e3e93b449c5501ef9d046244a71eb36db074 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:14:29 -0400 Subject: Fix trailing space --- examples/data/scripts/formfiller.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 564bf82..f6962c4 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -5,9 +5,9 @@ # uses settings files like: $keydir/ # files contain lines like: !profile= # (fieldtype): -# profile_name should be replaced with a name that will tell sth about that +# profile_name should be replaced with a name that will tell sth about that # profile -# fieldtype can be checkbox, text or password, textarea - only for information +# fieldtype can be checkbox, text or password, textarea - only for information # pupropse (auto-generated) - don't change that # # Texteares: for textareas edited text can be now splitted into more lines. -- cgit v1.2.3 From 391ffa73dfa46beea7dff2c9789a5f56a39227c4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:40:45 -0400 Subject: Migrate to using uzbl-dir util script --- examples/data/scripts/download.sh | 9 +++--- examples/data/scripts/formfiller.sh | 36 +++++++++++------------- examples/data/scripts/history.sh | 8 ++++-- examples/data/scripts/insert_bookmark.sh | 8 ++++-- examples/data/scripts/load_url_from_bookmarks.sh | 10 ++++--- examples/data/scripts/load_url_from_history.sh | 13 +++++---- examples/data/scripts/session.sh | 20 ++++++------- 7 files changed, 55 insertions(+), 49 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh index 0f051db..5b4baa7 100755 --- a/examples/data/scripts/download.sh +++ b/examples/data/scripts/download.sh @@ -2,10 +2,11 @@ # just an example of how you could handle your downloads # try some pattern matching on the uri to determine what we should do +source $UZBL_UTIL_DIR/uzbl-dir.sh + # Some sites block the default wget --user-agent.. -GET="wget --user-agent=Firefox --content-disposition --load-cookies=$XDG_DATA_HOME/uzbl/cookies.txt" +GET="wget --user-agent=Firefox --content-disposition --load-cookies=$UZBL_COOKIE_JAR" -dest="$HOME" url="$8" http_proxy="$9" @@ -15,7 +16,7 @@ test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; } # only changes the dir for the $get sub process if echo "$url" | grep -E '.*\.torrent' >/dev/null; then - ( cd "$dest"; $GET "$url") + ( cd "$UZBL_DOWNLOAD_DIR"; $GET "$url") else - ( cd "$dest"; $GET "$url") + ( cd "$UZBL_DOWNLOAD_DIR"; $GET "$url") fi diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index f6962c4..3aa1676 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -2,7 +2,7 @@ # # Enhanced html form (eg for logins) filler (and manager) for uzbl. # -# uses settings files like: $keydir/ +# uses settings files like: $UZBL_FORMS_DIR/ # files contain lines like: !profile= # (fieldtype): # profile_name should be replaced with a name that will tell sth about that @@ -49,13 +49,13 @@ else LINES="" fi +source $UZBL_UTIL_DIR/uzbl-dir.sh + PROMPT="Choose profile" MODELINE="> vim:ft=formfiller" -keydir=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/dforms - -[ -d "$(dirname $keydir)" ] || exit 1 -[ -d "$keydir" ] || mkdir "$keydir" +[ -d "$(dirname $UZBL_FORMS_DIR)" ] || exit 1 +[ -d $UZBL_FORMS_DIR ] || mkdir $UZBL_FORMS_DIR || exit 1 editor="${VISUAL}" if [ -z "${editor}" ]; then @@ -82,14 +82,12 @@ title=$1; shift action=$1 -[ -d $keydir ] || mkdir $keydir || exit 1 - domain=$(echo $url | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/') if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$action" != 'add' -a "$action" != 'once' ]; then action="new" - [ -e "$keydir/$domain" ] && action="load" -elif [ "$action" = 'edit' ] && [ ! -e "$keydir/$domain" ]; then + [ -e "$UZBL_FORMS_DIR/$domain" ] && action="load" +elif [ "$action" = 'edit' ] && [ ! -e "$UZBL_FORMS_DIR/$domain" ]; then action="new" fi @@ -150,9 +148,9 @@ insertFunction="function insert(fname, ftype, fvalue, fchecked) { \ }; " if [ "$action" = 'load' ]; then - [ -e $keydir/$domain ] || exit 2 - if [ $(cat $keydir/$domain | grep "!profile" | wc -l) -gt 1 ]; then - menu=$(cat $keydir/$domain | \ + [ -e $UZBL_FORMS_DIR/$domain ] || exit 2 + if [ $(cat $UZBL_FORMS_DIR/$domain | grep "!profile" | wc -l) -gt 1 ]; then + menu=$(cat $UZBL_FORMS_DIR/$domain | \ sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p') option=$(echo -e -n "$menu" | dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}") fi @@ -160,8 +158,8 @@ if [ "$action" = 'load' ]; then # Remove comments sed '/^>/d' -i $tmpfile - sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $keydir/$domain - fields=$(cat $keydir/$domain | \ + sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $UZBL_FORMS_DIR/$domain + fields=$(cat $UZBL_FORMS_DIR/$domain | \ sed -n "/^!profile=${option}/,/^!profile=/p" | \ sed '/^!profile=/d' | \ sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \ @@ -202,8 +200,8 @@ elif [ "$action" = "once" ]; then rm -f $tmpfile else if [ "$action" = 'new' -o "$action" = 'add' ]; then - [ "$action" = 'new' ] && echo "$MODELINE" > $keydir/$domain - echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain + [ "$action" = 'new' ] && echo "$MODELINE" > $UZBL_FORMS_DIR/$domain + echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $UZBL_FORMS_DIR/$domain # # 2. and 3. line (tr -d and sed) are because, on gmail login for example, # tag is splited into lines @@ -222,10 +220,10 @@ else # printf 'js %s dump(); \n' "$dumpFunction" | \ socat - unix-connect:$socket | \ - sed -n '/^[^(]\+([^)]\+):/p' >> $keydir/$domain + sed -n '/^[^(]\+([^)]\+):/p' >> $UZBL_FORMS_DIR/$domain fi - [ -e "$keydir/$domain" ] || exit 3 #this should never happen, but you never know. - $editor "$keydir/$domain" #TODO: if user aborts save in editor, the file is already overwritten + [ -e "$UZBL_FORMS_DIR/$domain" ] || exit 3 #this should never happen, but you never know. + $editor "$UZBL_FORMS_DIR/$domain" #TODO: if user aborts save in editor, the file is already overwritten fi # vim:fileencoding=utf-8:sw=4 diff --git a/examples/data/scripts/history.sh b/examples/data/scripts/history.sh index be5fd34..b91d415 100755 --- a/examples/data/scripts/history.sh +++ b/examples/data/scripts/history.sh @@ -1,5 +1,7 @@ #!/bin/sh -file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history -[ -d $(dirname $file) ] || exit 1 -echo $(date +'%Y-%m-%d %H:%M:%S')" $6 $7" >> $file +source $UZBL_UTIL_DIR/uzbl-dir.sh + +[ -w "$UZBL_HISTORY_FILE" ] || exit 1 + +echo $(date +'%Y-%m-%d %H:%M:%S')" $6 $7" >> $UZBL_HISTORY_FILE diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh index 4d29ad6..201bae0 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -1,7 +1,9 @@ #!/bin/sh -[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/uzbl" ] || exit 1 -file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks +source $UZBL_UTIL_DIR/uzbl-dir.sh + +[ -d "$UZBL_DATA_DIR" ] || exit 1 +[ -w "$UZBL_BOOKMARKS_FILE" ] || exit 1 which zenity &>/dev/null || exit 2 url=$6 @@ -14,5 +16,5 @@ url=$(echo $entry | awk '{print $1}') # TODO: check if already exists, if so, and tags are different: ask if you want to replace tags echo "$entry" >/dev/null #for some reason we need this.. don't ask me why -echo -e "$entry" >> $file +echo -e "$entry" >> $UZBL_BOOKMARKS_FILE true diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 3134407..9a955ec 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -2,17 +2,19 @@ #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. -file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks -[ -r "$file" ] || exit +source $UZBL_UTIL_DIR/uzbl-dir.sh + +[ -r "$UZBL_BOOKMARKS_FILE" ] || exit 1 + COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then DMENU="dmenu -i -xs -rs -l 10" # vertical patch # show tags as well - goto=$($DMENU $COLORS < $file | awk '{print $1}') + goto=$($DMENU $COLORS < $UZBL_BOOKMARKS_FILE | awk '{print $1}') else DMENU="dmenu -i" # because they are all after each other, just show the url, not their tags. - goto=$(awk '{print $1}' $file | $DMENU $COLORS) + goto=$(awk '{print $1}' $UZBL_BOOKMARKS_FILE | $DMENU $COLORS) fi #[ -n "$goto" ] && echo "uri $goto" > $4 diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index 5156eee..9fea1eb 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -1,21 +1,22 @@ #!/bin/sh -history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history -[ -r "$history_file" ] || exit 1 +source $UZBL_UTIL_DIR/uzbl-dir.sh + +[ -r "$UZBL_HISTORY_FILE" ] || exit 1 # choose from all entries, sorted and uniqued -# goto=$(awk '{print $3}' $history_file | sort -u | dmenu -i) +# goto=$(awk '{print $3}' $UZBL_HISTORY_FILE | sort -u | dmenu -i) COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then DMENU="dmenu -i -xs -rs -l 10" # vertical patch # choose an item in reverse order, showing also the date and page titles # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url. - goto=$(tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}') + goto=$(tac $UZBL_HISTORY_FILE | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}') else DMENU="dmenu -i" # choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order - current=$(tail -n 1 $history_file | awk '{print $3}'); - goto=$((echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" \ + current=$(tail -n 1 $UZBL_HISTORY_FILE | awk '{print $3}'); + goto=$((echo $current; awk '{print $3}' $UZBL_HISTORY_FILE | grep -v "^$current\$" \ | sort -u) | $DMENU $COLORS) fi diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index acd6934..68ce4d4 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -8,13 +8,13 @@ # and doesn't need to be called manually at any point. # Add a line like 'bind quit = /path/to/session.sh endsession' to your config -[ -d ${XDG_DATA_HOME:-$HOME/.local/share}/uzbl ] || exit 1 -scriptfile=$0 # this script -sessionfile=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/browser-session # the file in which the "session" (i.e. urls) are stored -configfile=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/config # uzbl configuration file -UZBL="uzbl-browser -c $configfile" # add custom flags and whatever here. +source $UZBL_UTIL_DIR/uzbl-dir.sh + +[ -d $UZBL_DATA_DIR ] || exit 1 + +scriptfile=$0 # this script +UZBL="uzbl-browser -c $UZBL_CONFIG_FILE" # add custom flags and whatever here. -fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere thisfifo="$4" act="$8" url="$6" @@ -26,7 +26,7 @@ fi case $act in "launch" ) - urls=$(cat $sessionfile) + urls=$(cat $UZBL_SESSION_FILE) if [ "$urls." = "." ]; then $UZBL else @@ -39,14 +39,14 @@ case $act in "endinstance" ) if [ "$url" != "(null)" ]; then - echo "$url" >> $sessionfile; + echo "$url" >> $UZBL_SESSION_FILE fi echo "exit" > "$thisfifo" ;; "endsession" ) - mv "$sessionfile" "$sessionfile~" - for fifo in $fifodir/uzbl_fifo_*; do + mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~" + for fifo in $UZBL_FIFO_DIR/uzbl_fifo_*; do if [ "$fifo" != "$thisfifo" ]; then echo "spawn $scriptfile endinstance" > "$fifo" fi -- cgit v1.2.3 From eeab3def726000c36cc0ba36ca0506b2eecbaf49 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:36:32 -0400 Subject: Migrate to using uzbl-args util script --- examples/data/scripts/download.sh | 5 ++-- examples/data/scripts/formfiller.sh | 29 +++++++----------------- examples/data/scripts/insert_bookmark.sh | 5 ++-- examples/data/scripts/load_url_from_bookmarks.sh | 5 ++-- examples/data/scripts/load_url_from_history.sh | 5 ++-- examples/data/scripts/session.sh | 21 +++++++++-------- 6 files changed, 30 insertions(+), 40 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh index 5b4baa7..f2ee4a8 100755 --- a/examples/data/scripts/download.sh +++ b/examples/data/scripts/download.sh @@ -2,14 +2,15 @@ # just an example of how you could handle your downloads # try some pattern matching on the uri to determine what we should do +source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh # Some sites block the default wget --user-agent.. GET="wget --user-agent=Firefox --content-disposition --load-cookies=$UZBL_COOKIE_JAR" -url="$8" +url="$1" -http_proxy="$9" +http_proxy="$2" export http_proxy test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; } diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 3aa1676..2c792bc 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -49,6 +49,7 @@ else LINES="" fi +source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh PROMPT="Choose profile" @@ -66,23 +67,9 @@ if [ -z "${editor}" ]; then fi fi -config=$1; -shift -pid=$1; -shift -xid=$1; -shift -fifo=$1; -shift -socket=$1; -shift -url=$1; -shift -title=$1; -shift action=$1 -domain=$(echo $url | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/') +domain=$(echo $UZBL_URL | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/') if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$action" != 'add' -a "$action" != 'once' ]; then action="new" @@ -168,14 +155,14 @@ if [ "$action" = 'load' ]; then sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g') printf '%s\n' "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo + sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $UZBL_FIFO printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ - sed -e 's/@/\\@/g' > $fifo + sed -e 's/@/\\@/g' > $UZBL_FIFO elif [ "$action" = "once" ]; then tmpfile=$(mktemp) printf 'js %s dump(); \n' "$dumpFunction" | \ - socat - unix-connect:$socket | \ + socat - unix-connect:$UZBL_SOCKET | \ sed -n '/^[^(]\+([^)]\+):/p' > $tmpfile echo "$MODELINE" >> $tmpfile ${editor} $tmpfile @@ -193,10 +180,10 @@ elif [ "$action" = "once" ]; then sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g') printf '%s\n' "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo + sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $UZBL_FIFO printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ - sed -e 's/@/\\@/g' > $fifo + sed -e 's/@/\\@/g' > $UZBL_FIFO rm -f $tmpfile else if [ "$action" = 'new' -o "$action" = 'add' ]; then @@ -219,7 +206,7 @@ else # passwd(password): # printf 'js %s dump(); \n' "$dumpFunction" | \ - socat - unix-connect:$socket | \ + socat - unix-connect:$UZBL_SOCKET | \ sed -n '/^[^(]\+([^)]\+):/p' >> $UZBL_FORMS_DIR/$domain fi [ -e "$UZBL_FORMS_DIR/$domain" ] || exit 3 #this should never happen, but you never know. diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh index 201bae0..18f643f 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -6,10 +6,9 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh [ -w "$UZBL_BOOKMARKS_FILE" ] || exit 1 which zenity &>/dev/null || exit 2 -url=$6 # replace tabs, they are pointless in titles and we want to use tabs as delimiter. -title=$(echo "$7" | sed 's/\t/ /') -entry=$(zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$url $title\t") +title=$(echo "$UZBL_TITLE" | sed 's/\t/ /') +entry=$(zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$UZBL_URL $title\t") exitstatus=$? if [ $exitstatus -ne 0 ]; then exit $exitstatus; fi url=$(echo $entry | awk '{print $1}') diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 9a955ec..3bcb60f 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -2,6 +2,7 @@ #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. +source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh [ -r "$UZBL_BOOKMARKS_FILE" ] || exit 1 @@ -17,5 +18,5 @@ else goto=$(awk '{print $1}' $UZBL_BOOKMARKS_FILE | $DMENU $COLORS) fi -#[ -n "$goto" ] && echo "uri $goto" > $4 -[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$5 +#[ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO +[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$UZBL_SOCKET diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index 9fea1eb..5aba844 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -1,5 +1,6 @@ #!/bin/sh +source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh [ -r "$UZBL_HISTORY_FILE" ] || exit 1 @@ -20,5 +21,5 @@ else | sort -u) | $DMENU $COLORS) fi -[ -n "$goto" ] && echo "uri $goto" > $4 -#[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$5 +[ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO +#[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$UZBL_SOCKET diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index 68ce4d4..1585159 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -8,6 +8,7 @@ # and doesn't need to be called manually at any point. # Add a line like 'bind quit = /path/to/session.sh endsession' to your config +source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh [ -d $UZBL_DATA_DIR ] || exit 1 @@ -15,12 +16,12 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh scriptfile=$0 # this script UZBL="uzbl-browser -c $UZBL_CONFIG_FILE" # add custom flags and whatever here. -thisfifo="$4" -act="$8" -url="$6" +act="$1" -if [ "$act." = "." ]; then - act="$1" +# Test if we were run alone or from uzbl +if [ "x$UZBL_FIFO" = "x" ]; then + # Take the old config + act="$UZBL_CONFIG" fi @@ -38,20 +39,20 @@ case $act in ;; "endinstance" ) - if [ "$url" != "(null)" ]; then - echo "$url" >> $UZBL_SESSION_FILE + if [ "$UZBL_URL" != "(null)" ]; then + echo "$UZBL_URL" >> $UZBL_SESSION_FILE fi - echo "exit" > "$thisfifo" + echo "exit" > "$UZBL_FIFO" ;; "endsession" ) mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~" for fifo in $UZBL_FIFO_DIR/uzbl_fifo_*; do - if [ "$fifo" != "$thisfifo" ]; then + if [ "$fifo" != "$UZBL_FIFO" ]; then echo "spawn $scriptfile endinstance" > "$fifo" fi done - echo "spawn $scriptfile endinstance" > "$thisfifo" + echo "spawn $scriptfile endinstance" > "$UZBL_FIFO" ;; * ) echo "session manager: bad action" -- cgit v1.2.3 From 8eed5f24a0d40574433c3f3a945e6aac75e06aba Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:37:25 -0400 Subject: Migrate to using the dmenu util script --- examples/data/scripts/formfiller.sh | 19 ++++++------------- examples/data/scripts/instance-select-wmii.sh | 10 ++-------- examples/data/scripts/load_url_from_bookmarks.sh | 14 ++++++-------- examples/data/scripts/load_url_from_history.sh | 21 +++++++++------------ 4 files changed, 23 insertions(+), 41 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 2c792bc..cf8e46b 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -37,22 +37,15 @@ # something else (or empty): if file not available: new, otherwise load. # -# config dmenu colors and prompt -NB="#0f0f0f" -NF="#4e7093" -SB="#003d7c" -SF="#3a9bff" - -if [ "$(dmenu --help 2>&1 | grep lines)x" != "x" ]; then - LINES=" -l 3 " -else - LINES="" -fi +DMENU_ARGS="-i" +DMENU_SCHEMA="formfiller" +DMENU_LINES="3" +DMENU_PROMPT="Choose profile" +source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh -PROMPT="Choose profile" MODELINE="> vim:ft=formfiller" [ -d "$(dirname $UZBL_FORMS_DIR)" ] || exit 1 @@ -139,7 +132,7 @@ if [ "$action" = 'load' ]; then if [ $(cat $UZBL_FORMS_DIR/$domain | grep "!profile" | wc -l) -gt 1 ]; then menu=$(cat $UZBL_FORMS_DIR/$domain | \ sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p') - option=$(echo -e -n "$menu" | dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}") + option=$(echo -e -n "$menu" | $DMENU) fi # Remove comments diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh index 1340351..82acf3b 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -11,13 +11,7 @@ # See http://www.uzbl.org/wiki/wmii for more info # $1 must be one of 'list', 'next', 'prev' -COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" - -if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then - DMENU="dmenu -i -xs -rs -l 10" # vertical patch -else - DMENU="dmenu -i" -fi +source $UZBL_UTIL_DIR/dmenu.sh if [ "$1" == 'list' ]; then list= @@ -26,7 +20,7 @@ if [ "$1" == 'list' ]; then label=$(wmiir read /client/$i/label) list="$list$i : $label\n" done - window=$(echo -e "$list" | $DMENU $COLORS | cut -d ' ' -f1) + window=$(echo -e "$list" | $DMENU | cut -d ' ' -f1) wmiir xwrite /tag/sel/ctl "select client $window" elif [ "$1" == 'next' ]; then current=$(wmiir read /client/sel/ctl | head -n 1) diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 3bcb60f..1cf8ea4 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -2,20 +2,18 @@ #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. +source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh [ -r "$UZBL_BOOKMARKS_FILE" ] || exit 1 -COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" -if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then - DMENU="dmenu -i -xs -rs -l 10" # vertical patch - # show tags as well - goto=$($DMENU $COLORS < $UZBL_BOOKMARKS_FILE | awk '{print $1}') +if [ "x$DMENU_HAS_VERTICAL" = "x" ]; then + # because they are all after each other, just show the url, not their tags. + goto=$(awk '{print $1}' $UZBL_BOOKMARKS_FILE | $DMENU) else - DMENU="dmenu -i" - # because they are all after each other, just show the url, not their tags. - goto=$(awk '{print $1}' $UZBL_BOOKMARKS_FILE | $DMENU $COLORS) + # show tags as well + goto=$($DMENU < $UZBL_BOOKMARKS_FILE | awk '{print $1}') fi #[ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index 5aba844..f79e018 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -1,24 +1,21 @@ #!/bin/sh +source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh [ -r "$UZBL_HISTORY_FILE" ] || exit 1 # choose from all entries, sorted and uniqued -# goto=$(awk '{print $3}' $UZBL_HISTORY_FILE | sort -u | dmenu -i) -COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" -if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'; then - DMENU="dmenu -i -xs -rs -l 10" # vertical patch - # choose an item in reverse order, showing also the date and page titles - # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url. - goto=$(tac $UZBL_HISTORY_FILE | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}') +# goto=$(awk '{print $3}' $history_file | sort -u | dmenu -i) +if [ "x$DMENU_HAS_VERTICAL" = "x" ]; then + current=$(tail -n 1 $UZBL_HISTORY_FILE | awk '{print $3}'); + goto=$((echo $current; awk '{print $3}' $UZBL_HISTORY_FILE | grep -v "^$current\$" \ + | sort -u) | $DMENU) else - DMENU="dmenu -i" - # choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order - current=$(tail -n 1 $UZBL_HISTORY_FILE | awk '{print $3}'); - goto=$((echo $current; awk '{print $3}' $UZBL_HISTORY_FILE | grep -v "^$current\$" \ - | sort -u) | $DMENU $COLORS) + # choose an item in reverse order, showing also the date and page titles + # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url. + goto=$(tac $UZBL_HISTORY_FILE | $DMENU | cut -d ' ' -f -3 | awk '{print $NF}') fi [ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO -- cgit v1.2.3 From 36b6240a73ceb9d7b5c504e960d491693de98199 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:37:46 -0400 Subject: Migrate to using the editor util script --- examples/data/scripts/formfiller.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index cf8e46b..fb1eb02 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -43,6 +43,7 @@ DMENU_LINES="3" DMENU_PROMPT="Choose profile" source $UZBL_UTIL_DIR/dmenu.sh +source $UZBL_UTIL_DIR/editor.sh source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh @@ -51,15 +52,6 @@ MODELINE="> vim:ft=formfiller" [ -d "$(dirname $UZBL_FORMS_DIR)" ] || exit 1 [ -d $UZBL_FORMS_DIR ] || mkdir $UZBL_FORMS_DIR || exit 1 -editor="${VISUAL}" -if [ -z "${editor}" ]; then - if [ -z "${EDITOR}" ]; then - editor='xterm -e vim' - else - editor="xterm -e ${EDITOR}" - fi -fi - action=$1 domain=$(echo $UZBL_URL | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/') @@ -158,7 +150,7 @@ elif [ "$action" = "once" ]; then socat - unix-connect:$UZBL_SOCKET | \ sed -n '/^[^(]\+([^)]\+):/p' > $tmpfile echo "$MODELINE" >> $tmpfile - ${editor} $tmpfile + $UZBL_EDITOR $tmpfile [ -e $tmpfile ] || exit 2 @@ -203,7 +195,7 @@ else sed -n '/^[^(]\+([^)]\+):/p' >> $UZBL_FORMS_DIR/$domain fi [ -e "$UZBL_FORMS_DIR/$domain" ] || exit 3 #this should never happen, but you never know. - $editor "$UZBL_FORMS_DIR/$domain" #TODO: if user aborts save in editor, the file is already overwritten + $UZBL_EDITOR "$UZBL_FORMS_DIR/$domain" #TODO: if user aborts save in editor, the file is already overwritten fi # vim:fileencoding=utf-8:sw=4 -- cgit v1.2.3 From 8c19571e0890d7a4922eb461147749e9f65a7be4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:45:52 -0400 Subject: Match indentation in session.sh to match others --- examples/data/scripts/session.sh | 70 ++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index 1585159..385b40c 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -24,40 +24,40 @@ if [ "x$UZBL_FIFO" = "x" ]; then act="$UZBL_CONFIG" fi - case $act in - "launch" ) - urls=$(cat $UZBL_SESSION_FILE) - if [ "$urls." = "." ]; then - $UZBL - else - for url in $urls; do - $UZBL --uri "$url" & - done - fi - exit 0 - ;; - - "endinstance" ) - if [ "$UZBL_URL" != "(null)" ]; then - echo "$UZBL_URL" >> $UZBL_SESSION_FILE - fi - echo "exit" > "$UZBL_FIFO" - ;; - - "endsession" ) - mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~" - for fifo in $UZBL_FIFO_DIR/uzbl_fifo_*; do - if [ "$fifo" != "$UZBL_FIFO" ]; then - echo "spawn $scriptfile endinstance" > "$fifo" - fi - done - echo "spawn $scriptfile endinstance" > "$UZBL_FIFO" - ;; - - * ) echo "session manager: bad action" - echo "Usage: $scriptfile [COMMAND] where commands are:" - echo " launch - Restore a saved session or start a new one" - echo " endsession - Quit the running session. Must be called from uzbl" - ;; + "launch" ) + urls=$(cat $UZBL_SESSION_FILE) + if [ "$urls." = "." ]; then + $UZBL + else + for url in $urls; do + $UZBL --uri "$url" & + done + fi + exit 0 + ;; + + "endinstance" ) + if [ ! "$UZBL_URL" = "(null)" ]; then + echo "$UZBL_URL" >> $UZBL_SESSION_FILE + fi + echo "exit" > "$UZBL_FIFO" + ;; + + "endsession" ) + mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~" + for fifo in $UZBL_FIFO_DIR/uzbl_fifo_*; do + if [ "$fifo" != "$UZBL_FIFO" ]; then + echo "spawn $scriptfile endinstance" > "$fifo" + fi + done + echo "spawn $scriptfile endinstance" > "$UZBL_FIFO" + ;; + + * ) + echo "session manager: bad action" + echo "Usage: $scriptfile [COMMAND] where commands are:" + echo " launch - Restore a saved session or start a new one" + echo " endsession - Quit the running session. Must be called from uzbl" + ;; esac -- cgit v1.2.3 From 0c62bcfc3e5abbee44c2bbbfc236f7e3e3f2aa1e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:46:11 -0400 Subject: Fix empty string check --- examples/data/scripts/session.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index 385b40c..ecd6b1a 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -27,7 +27,7 @@ fi case $act in "launch" ) urls=$(cat $UZBL_SESSION_FILE) - if [ "$urls." = "." ]; then + if [ "x$urls" = "x" ]; then $UZBL else for url in $urls; do -- cgit v1.2.3 From f00cd76d9e3e7f70afc5ed0b616c0c6582f81845 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:46:32 -0400 Subject: Disown the process as well --- examples/data/scripts/session.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'examples') diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index ecd6b1a..d7bb322 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -32,6 +32,7 @@ case $act in else for url in $urls; do $UZBL --uri "$url" & + disown done fi exit 0 -- cgit v1.2.3 From 75841cf0ca5c2790cb589a592c8af683fe04cbad Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:46:48 -0400 Subject: Check to make sure uzbl called endinstance --- examples/data/scripts/session.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'examples') diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index d7bb322..c226c29 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -39,6 +39,10 @@ case $act in ;; "endinstance" ) + if [ "x$UZBL_FIFO" = "x" ]; then + echo "session manager: endinstance must be called from uzbl" + exit 1 + fi if [ ! "$UZBL_URL" = "(null)" ]; then echo "$UZBL_URL" >> $UZBL_SESSION_FILE fi -- cgit v1.2.3 From 5f6d5a160485f262fbff74d1c1c8565702bc6f6e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:47:14 -0400 Subject: Fix usage message --- examples/data/scripts/session.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index c226c29..d30f3da 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -62,7 +62,8 @@ case $act in * ) echo "session manager: bad action" echo "Usage: $scriptfile [COMMAND] where commands are:" - echo " launch - Restore a saved session or start a new one" - echo " endsession - Quit the running session. Must be called from uzbl" + echo " launch - Restore a saved session or start a new one" + echo " endinstance - Quit the current instance. Must be called from uzbl" + echo " endsession - Quit the running session." ;; esac -- cgit v1.2.3 From a2901d469cacd317e8995486401f363bc569d37c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 11:47:25 -0400 Subject: Loading from bookmarks is now POSIX sh --- examples/data/scripts/load_url_from_bookmarks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 1cf8ea4..d5f7bd6 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. -- cgit v1.2.3 From e0e443e5c5bbd7663542788401d0e44da91e301e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:02:11 -0400 Subject: Use -z and -n tests rather than "x$foo" = "x" hack --- examples/data/scripts/download.sh | 5 ++++- examples/data/scripts/instance-select-wmii.sh | 4 ++-- examples/data/scripts/load_url_from_bookmarks.sh | 2 +- examples/data/scripts/load_url_from_history.sh | 2 +- examples/data/scripts/session.sh | 6 +++--- examples/data/scripts/util/dmenu.sh | 6 +++--- examples/data/scripts/util/editor.sh | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh index f2ee4a8..7375535 100755 --- a/examples/data/scripts/download.sh +++ b/examples/data/scripts/download.sh @@ -13,7 +13,10 @@ url="$1" http_proxy="$2" export http_proxy -test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; } +if [ -z "$url" ]; then + echo "you must supply a url! ($url)" + exit 1 +fi # only changes the dir for the $get sub process if echo "$url" | grep -E '.*\.torrent' >/dev/null; then diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh index 82acf3b..dcb8866 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -26,13 +26,13 @@ elif [ "$1" == 'next' ]; then current=$(wmiir read /client/sel/ctl | head -n 1) # find the next uzbl window and focus it next=$(wmiir read /tag/sel/index | grep -A 10000 " $current " | grep -m 1 uzbl | cut -d ' ' -f2) - if [ x"$next" != "x" ]; then + if [ -n "$next" ]; then wmiir xwrite /tag/sel/ctl "select client $next" fi elif [ "$1" == 'prev' ]; then current=$(wmiir read /client/sel/ctl | head -n 1) prev=$(wmiir read /tag/sel/index | grep -B 10000 " $current " | tac | grep -m 1 uzbl | cut -d ' ' -f2) - if [ x"$prev" != "x" ]; then + if [ -n "$prev" ]; then wmiir xwrite /tag/sel/ctl "select client $prev" fi else diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index d5f7bd6..7613624 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -8,7 +8,7 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh [ -r "$UZBL_BOOKMARKS_FILE" ] || exit 1 -if [ "x$DMENU_HAS_VERTICAL" = "x" ]; then +if [ -z "$DMENU_HAS_VERTICAL" ]; then # because they are all after each other, just show the url, not their tags. goto=$(awk '{print $1}' $UZBL_BOOKMARKS_FILE | $DMENU) else diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index f79e018..ca8959c 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -8,7 +8,7 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh # choose from all entries, sorted and uniqued # goto=$(awk '{print $3}' $history_file | sort -u | dmenu -i) -if [ "x$DMENU_HAS_VERTICAL" = "x" ]; then +if [ -z "$DMENU_HAS_VERTICAL" ]; then current=$(tail -n 1 $UZBL_HISTORY_FILE | awk '{print $3}'); goto=$((echo $current; awk '{print $3}' $UZBL_HISTORY_FILE | grep -v "^$current\$" \ | sort -u) | $DMENU) diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index d30f3da..3f1c6d3 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -19,7 +19,7 @@ UZBL="uzbl-browser -c $UZBL_CONFIG_FILE" # add custom flags and whatever here. act="$1" # Test if we were run alone or from uzbl -if [ "x$UZBL_FIFO" = "x" ]; then +if [ -z "$UZBL_FIFO" ]; then # Take the old config act="$UZBL_CONFIG" fi @@ -27,7 +27,7 @@ fi case $act in "launch" ) urls=$(cat $UZBL_SESSION_FILE) - if [ "x$urls" = "x" ]; then + if [ -z "$urls" ]; then $UZBL else for url in $urls; do @@ -39,7 +39,7 @@ case $act in ;; "endinstance" ) - if [ "x$UZBL_FIFO" = "x" ]; then + if [ -z "$UZBL_FIFO" ]; then echo "session manager: endinstance must be called from uzbl" exit 1 fi diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh index 3f307f2..2326cea 100644 --- a/examples/data/scripts/util/dmenu.sh +++ b/examples/data/scripts/util/dmenu.sh @@ -40,12 +40,12 @@ case "$DMENU_SCHEME" in esac # Default arguments -if [ "x$DMENU_ARGS" = "x" ]; then +if [ -z "$DMENU_ARGS" ]; then DMENU_ARGS="-i" fi # Set the prompt if wanted -if [ ! "x$DMENU_PROMPT" = "x" ]; then +if [ -n "$DMENU_PROMPT" ]; then DMENU_ARGS="$DMENU_ARGS -p $DMENU_PROMPT" fi @@ -58,7 +58,7 @@ fi # Detect the vertical patch if dmenu --help 2>&1 | grep -q '\[-l lines\]'; then # Default to 10 lines - if [ "x$DMENU_LINES" = "x" ]; then + if [ -z "$DMENU_LINES" ]; then DMENU_LINES=10 fi diff --git a/examples/data/scripts/util/editor.sh b/examples/data/scripts/util/editor.sh index a152ebd..1969769 100644 --- a/examples/data/scripts/util/editor.sh +++ b/examples/data/scripts/util/editor.sh @@ -1,7 +1,7 @@ #!/bin/sh # Editor selection -if [ "x$VTERM" = "x" ]; then +if [ -z "$VTERM" ]; then VTERM="xterm" fi -- cgit v1.2.3 From cfd3ff8fcff8aad7b57d8b757c2401f58aebd561 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:02:43 -0400 Subject: Use a case statement in the wmii script --- examples/data/scripts/instance-select-wmii.sh | 57 +++++++++++++++------------ 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh index dcb8866..1fc6ed0 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -13,29 +13,34 @@ source $UZBL_UTIL_DIR/dmenu.sh -if [ "$1" == 'list' ]; then - list= - # get window id's of uzbl clients. we could also get the label in one shot but it's pretty tricky - for i in $(wmiir read /tag/sel/index | grep uzbl |cut -d ' ' -f2); do - label=$(wmiir read /client/$i/label) - list="$list$i : $label\n" - done - window=$(echo -e "$list" | $DMENU | cut -d ' ' -f1) - wmiir xwrite /tag/sel/ctl "select client $window" -elif [ "$1" == 'next' ]; then - current=$(wmiir read /client/sel/ctl | head -n 1) - # find the next uzbl window and focus it - next=$(wmiir read /tag/sel/index | grep -A 10000 " $current " | grep -m 1 uzbl | cut -d ' ' -f2) - if [ -n "$next" ]; then - wmiir xwrite /tag/sel/ctl "select client $next" - fi -elif [ "$1" == 'prev' ]; then - current=$(wmiir read /client/sel/ctl | head -n 1) - prev=$(wmiir read /tag/sel/index | grep -B 10000 " $current " | tac | grep -m 1 uzbl | cut -d ' ' -f2) - if [ -n "$prev" ]; then - wmiir xwrite /tag/sel/ctl "select client $prev" - fi -else - echo "\$1 not valid" >&2 - exit 2 -fi +case "$1" in + "list" ) + list= + # get window id's of uzbl clients. we could also get the label in one shot but it's pretty tricky + for i in $(wmiir read /tag/sel/index | grep uzbl |cut -d ' ' -f2); do + label=$(wmiir read /client/$i/label) + list="$list$i : $label\n" + done + window=$(echo -e "$list" | $DMENU | cut -d ' ' -f1) + wmiir xwrite /tag/sel/ctl "select client $window" + ;; + "next" ) + current=$(wmiir read /client/sel/ctl | head -n 1) + # find the next uzbl window and focus it + next=$(wmiir read /tag/sel/index | grep -A 10000 " $current " | grep -m 1 uzbl | cut -d ' ' -f2) + if [ -n "$next" ]; then + wmiir xwrite /tag/sel/ctl "select client $next" + fi + ;; + "prev" ) + current=$(wmiir read /client/sel/ctl | head -n 1) + prev=$(wmiir read /tag/sel/index | grep -B 10000 " $current " | tac | grep -m 1 uzbl | cut -d ' ' -f2) + if [ -n "$prev" ]; then + wmiir xwrite /tag/sel/ctl "select client $prev" + fi + ;; + * ) + echo "$1 not valid" >&2 + exit 2 + ;; +esac -- cgit v1.2.3 From 444be23decea26ea40090a909b36fd23516a88b4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:03:08 -0400 Subject: Quotes really needed here? --- examples/data/scripts/session.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index 3f1c6d3..64d8c6b 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -46,17 +46,17 @@ case $act in if [ ! "$UZBL_URL" = "(null)" ]; then echo "$UZBL_URL" >> $UZBL_SESSION_FILE fi - echo "exit" > "$UZBL_FIFO" + echo "exit" > $UZBL_FIFO ;; "endsession" ) mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~" for fifo in $UZBL_FIFO_DIR/uzbl_fifo_*; do if [ "$fifo" != "$UZBL_FIFO" ]; then - echo "spawn $scriptfile endinstance" > "$fifo" + echo "spawn $scriptfile endinstance" > $fifo fi done - echo "spawn $scriptfile endinstance" > "$UZBL_FIFO" + echo "spawn $scriptfile endinstance" > $UZBL_FIFO ;; * ) -- cgit v1.2.3 From 01d32f99ff5b0fb3d195ad9816e992a8267ec7b9 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:07:14 -0400 Subject: Add directory for the sockets as well --- examples/data/scripts/util/uzbl-dir.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'examples') diff --git a/examples/data/scripts/util/uzbl-dir.sh b/examples/data/scripts/util/uzbl-dir.sh index 01fb469..bb56954 100644 --- a/examples/data/scripts/util/uzbl-dir.sh +++ b/examples/data/scripts/util/uzbl-dir.sh @@ -5,6 +5,7 @@ UZBL_DATA_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl UZBL_CONFIG_DIR=${XDG_CONFIG_DIR:-$HOME/.config}/uzbl UZBL_FIFO_DIR=/tmp +UZBL_SOCKET_DIR=/tmp # Directories UZBL_DOWNLOAD_DIR=${XDG_DOWNLOAD_DIR:-$HOME} -- cgit v1.2.3 From 90ebadae7fa7843ed4a43c03e344d0e8cdebc936 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:07:34 -0400 Subject: Prefer sockets to fifos --- examples/data/scripts/formfiller.sh | 8 ++++---- examples/data/scripts/load_url_from_history.sh | 4 ++-- examples/data/scripts/session.sh | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index fb1eb02..041c6a6 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -140,10 +140,10 @@ if [ "$action" = 'load' ]; then sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g') printf '%s\n' "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $UZBL_FIFO + sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' | socat - unix-connect:$UZBL_SOCKET printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ - sed -e 's/@/\\@/g' > $UZBL_FIFO + sed -e 's/@/\\@/g' | socat - unix-connect:$UZBL_SOCKET elif [ "$action" = "once" ]; then tmpfile=$(mktemp) printf 'js %s dump(); \n' "$dumpFunction" | \ @@ -165,10 +165,10 @@ elif [ "$action" = "once" ]; then sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g') printf '%s\n' "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $UZBL_FIFO + sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' | socat - unix-connect:$UZBL_SOCKET printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ - sed -e 's/@/\\@/g' > $UZBL_FIFO + sed -e 's/@/\\@/g' | socat - unix-connect:$UZBL_SOCKET rm -f $tmpfile else if [ "$action" = 'new' -o "$action" = 'add' ]; then diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index ca8959c..80cd3d8 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -18,5 +18,5 @@ else goto=$(tac $UZBL_HISTORY_FILE | $DMENU | cut -d ' ' -f -3 | awk '{print $NF}') fi -[ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO -#[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$UZBL_SOCKET +#[ -n "$goto" ] && echo "uri $goto" > $UZBL_FIFO +[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$UZBL_SOCKET diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index 64d8c6b..89eeb7a 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -19,7 +19,7 @@ UZBL="uzbl-browser -c $UZBL_CONFIG_FILE" # add custom flags and whatever here. act="$1" # Test if we were run alone or from uzbl -if [ -z "$UZBL_FIFO" ]; then +if [ -z "$UZBL_SOCKET" ]; then # Take the old config act="$UZBL_CONFIG" fi @@ -39,24 +39,24 @@ case $act in ;; "endinstance" ) - if [ -z "$UZBL_FIFO" ]; then + if [ -z "$UZBL_SOCKET" ]; then echo "session manager: endinstance must be called from uzbl" exit 1 fi if [ ! "$UZBL_URL" = "(null)" ]; then echo "$UZBL_URL" >> $UZBL_SESSION_FILE fi - echo "exit" > $UZBL_FIFO + echo "exit" | socat - unix-connect:$UZBL_SOCKET ;; "endsession" ) mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~" - for fifo in $UZBL_FIFO_DIR/uzbl_fifo_*; do - if [ "$fifo" != "$UZBL_FIFO" ]; then - echo "spawn $scriptfile endinstance" > $fifo + for sock in $UZBL_SOCKET_DIR/uzbl_fifo_*; do + if [ "$sock" != "$UZBL_SOCKET" ]; then + echo "spawn $scriptfile endinstance" | socat - unix-connect:$socket fi done - echo "spawn $scriptfile endinstance" > $UZBL_FIFO + echo "spawn $scriptfile endinstance" | socat - unix-connect:$UZBL_SOCKET ;; * ) -- cgit v1.2.3 From c30ba29c31941e4ebc4322636e3fe435f1097aaa Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:11:15 -0400 Subject: Fix detection of the vertical patch --- examples/data/scripts/util/dmenu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh index 2326cea..2972663 100644 --- a/examples/data/scripts/util/dmenu.sh +++ b/examples/data/scripts/util/dmenu.sh @@ -56,7 +56,7 @@ if dmenu --help 2>&1 | grep -q '\[-xs\]'; then fi # Detect the vertical patch -if dmenu --help 2>&1 | grep -q '\[-l lines\]'; then +if dmenu --help 2>&1 | grep -q '\[-l \]'; then # Default to 10 lines if [ -z "$DMENU_LINES" ]; then DMENU_LINES=10 -- cgit v1.2.3 From aabbcdc4faa4447159606b8a5a70bf17002ba310 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:14:44 -0400 Subject: Make a variable for dmenu color arguments --- examples/data/scripts/util/dmenu.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh index 2972663..d1411c7 100644 --- a/examples/data/scripts/util/dmenu.sh +++ b/examples/data/scripts/util/dmenu.sh @@ -39,6 +39,8 @@ case "$DMENU_SCHEME" in ;; esac +DMENU_COLORS="-nb $NB -nf $NF -sb $SB -sf $SF" + # Default arguments if [ -z "$DMENU_ARGS" ]; then DMENU_ARGS="-i" @@ -71,4 +73,4 @@ if dmenu --help 2>&1 | grep -q '\[-l \]'; then fi fi -DMENU="dmenu $DMENU_ARGS -nb $NB -nf $NF -sb $SB -sf $SF" +DMENU="dmenu $DMENU_ARGS $DMENU_COLORS" -- cgit v1.2.3 From 1fcdfb3a104b44d80300f77f31d6192c3560d8e7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Aug 2010 12:16:19 -0400 Subject: Support setting the dmenu font --- examples/data/scripts/util/dmenu.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'examples') diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh index d1411c7..7d540bd 100644 --- a/examples/data/scripts/util/dmenu.sh +++ b/examples/data/scripts/util/dmenu.sh @@ -46,6 +46,11 @@ if [ -z "$DMENU_ARGS" ]; then DMENU_ARGS="-i" fi +# Set the font if wanted +if [ -n "$DMENU_FONT" ]; then + DMENU_ARGS="$DMENU_ARGS -fn $DMENU_FONT" +fi + # Set the prompt if wanted if [ -n "$DMENU_PROMPT" ]; then DMENU_ARGS="$DMENU_ARGS -p $DMENU_PROMPT" -- cgit v1.2.3 From 7244ebde733e0578d8d617275f1bcaa5947bc935 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 13:30:21 -0400 Subject: Fix the default configuration to support utils --- examples/config/config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/config/config b/examples/config/config index 81aa464..847b4af 100644 --- a/examples/config/config +++ b/examples/config/config @@ -34,7 +34,8 @@ set set_mode = set mode = set set_status = set status_message = # Spawn path shortcuts. In spawn the first dir+path match is used in "dir1:dir2:dir3:executable" -set scripts_dir = $XDG_DATA_HOME/uzbl:@prefix/share/uzbl/examples/data:scripts +set scripts_dir = $XDG_DATA_HOME/uzbl:@prefix/share/uzbl/examples/data:scripts +set scripts_util_dir = @scripts_dir/util # === Hardcoded handlers ===================================================== -- cgit v1.2.3 From fa27c93805d19d9aabae896a359b77767afc9de0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 15:50:19 -0400 Subject: Set the dmenu theme properly --- examples/data/scripts/instance-select-wmii.sh | 2 ++ examples/data/scripts/load_url_from_bookmarks.sh | 2 ++ examples/data/scripts/load_url_from_history.sh | 2 ++ 3 files changed, 6 insertions(+) (limited to 'examples') diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh index 1fc6ed0..967d7ad 100755 --- a/examples/data/scripts/instance-select-wmii.sh +++ b/examples/data/scripts/instance-select-wmii.sh @@ -11,6 +11,8 @@ # See http://www.uzbl.org/wiki/wmii for more info # $1 must be one of 'list', 'next', 'prev' +DMENU_SCHEME="wmii" + source $UZBL_UTIL_DIR/dmenu.sh case "$1" in diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 7613624..2c2a926 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -2,6 +2,8 @@ #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. +DMENU_SCHEME="bookmarks" + source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index 80cd3d8..2d15b4f 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -1,5 +1,7 @@ #!/bin/sh +DMENU_SCHEME="history" + source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/uzbl-args.sh source $UZBL_UTIL_DIR/uzbl-dir.sh -- cgit v1.2.3 From 5745a8f9f37fb233f1d5e1b7e1be3c8f8db7be54 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 15:51:33 -0400 Subject: Make xmms an option even if found --- examples/data/scripts/util/dmenu.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh index 7d540bd..9890b02 100644 --- a/examples/data/scripts/util/dmenu.sh +++ b/examples/data/scripts/util/dmenu.sh @@ -58,8 +58,12 @@ fi # Detect the xmms patch if dmenu --help 2>&1 | grep -q '\[-xs\]'; then - DMENU_ARGS="$DMENU_ARGS -xs" + DMENU_XMMS_ARGS="-xs" DMENU_HAS_XMMS=1 + + if echo $DMENU_OPTIONS | grep -q -w 'xmms'; then + DMENU_ARGS="$DMENU_ARGS $DMENU_XMMS_ARGS" + fi fi # Detect the vertical patch -- cgit v1.2.3 From 505114b665757bace138f54b6bba22869f6835f6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 15:52:00 -0400 Subject: Make vertical mode an option even if found --- examples/data/scripts/util/dmenu.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh index 9890b02..8113c3b 100644 --- a/examples/data/scripts/util/dmenu.sh +++ b/examples/data/scripts/util/dmenu.sh @@ -73,12 +73,21 @@ if dmenu --help 2>&1 | grep -q '\[-l \]'; then DMENU_LINES=10 fi - DMENU_ARGS="$DMENU_ARGS -l $DMENU_LINES" + DMENU_VERTICAL_ARGS="-l $DMENU_LINES" DMENU_HAS_VERTICAL=1 # Detect the resize patch if dmenu --help 2>&1 | grep -q '\[-rs\]'; then - DMENU_ARGS="$DMENU_ARGS -rs" + DMENU_RESIZE_ARGS="-rs" + DMENU_HAS_RESIZE=1 + fi + + if echo $DMENU_OPTIONS | grep -q -w 'vertical'; then + DMENU_ARGS="$DMENU_ARGS $DMENU_VERTICAL_ARGS" + + if echo $DMENU_OPTIONS | grep -q -w 'resize'; then + DMENU_ARGS="$DMENU_ARGS $DMENU_RESIZE_ARGS" + fi fi fi -- cgit v1.2.3 From 310bff511a3fd53a30449e32b4f13bb1bc1f51c7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 15:52:18 -0400 Subject: Detect the placement patch --- examples/data/scripts/util/dmenu.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'examples') diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh index 8113c3b..757e5cd 100644 --- a/examples/data/scripts/util/dmenu.sh +++ b/examples/data/scripts/util/dmenu.sh @@ -91,4 +91,13 @@ if dmenu --help 2>&1 | grep -q '\[-l \]'; then fi fi +# Detect placement patch +if dmenu --help 2>&1 | grep -q '\[-x \]'; then + DMENU_PLACE_X="-x" + DMENU_PLACE_Y="-y" + DMENU_PLACE_WIDTH="-w" + DMENU_PLACE_HEIGHT="-h" + DMENU_HAS_PLACEMENT=1 +fi + DMENU="dmenu $DMENU_ARGS $DMENU_COLORS" -- cgit v1.2.3 From f6441475cdd4ff435d35e8692ee52b885b17f809 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 15:52:38 -0400 Subject: Add utility script to find the window geometry --- examples/data/scripts/util/uzbl-window.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/data/scripts/util/uzbl-window.sh (limited to 'examples') diff --git a/examples/data/scripts/util/uzbl-window.sh b/examples/data/scripts/util/uzbl-window.sh new file mode 100644 index 0000000..b2771e4 --- /dev/null +++ b/examples/data/scripts/util/uzbl-window.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# uzbl window detection + +if [ -z "$UZBL_XID" ]; then + echo "Error: UZBL_XID not set" + echo "Please source uzbl-args.sh first" + exit 1 +fi + +UZBL_WIN_POS=$(xwininfo -id $UZBL_XID | \ + sed -ne 's/Corners:[ ]*[+-]\([0-9]*\)[+-]\([0-9]*\).*$/\1 \2/p') +UZBL_WIN_SIZE=$(xwininfo -id $UZBL_XID | \ + sed -ne 's/-geometry[ ]*\([0-9]*\)x\([0-9]*\).*$/\1 \2/p') +UZBL_WIN_POS_X=$(echo $UZBL_WIN_POS | cut -d\ -f1) +UZBL_WIN_POS_Y=$(echo $UZBL_WIN_POS | cut -d\ -f2) +UZBL_WIN_WIDTH=$(echo $UZBL_WIN_SIZE | cut -d\ -f1) +UZBL_WIN_HEIGHT=$(echo $UZBL_WIN_SIZE | cut -d\ -f2) -- cgit v1.2.3 From ca680c621b57048f781f154d1e65009aa0001906 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 15:53:51 -0400 Subject: Set defaults for loading bookmarks and history --- examples/data/scripts/load_url_from_bookmarks.sh | 1 + examples/data/scripts/load_url_from_history.sh | 1 + 2 files changed, 2 insertions(+) (limited to 'examples') diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh index 2c2a926..564c3f8 100755 --- a/examples/data/scripts/load_url_from_bookmarks.sh +++ b/examples/data/scripts/load_url_from_bookmarks.sh @@ -3,6 +3,7 @@ #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. DMENU_SCHEME="bookmarks" +DMENU_OPTIONS="xmms vertical resize" source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/uzbl-args.sh diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh index 2d15b4f..d094625 100755 --- a/examples/data/scripts/load_url_from_history.sh +++ b/examples/data/scripts/load_url_from_history.sh @@ -1,6 +1,7 @@ #!/bin/sh DMENU_SCHEME="history" +DMENU_OPTIONS="xmms vertical resize" source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/uzbl-args.sh -- cgit v1.2.3 From 400b23552e7a4e8f1219c677dc491f35e22d335a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 15:55:17 -0400 Subject: Prefer vertical and resizing in formfiller --- examples/data/scripts/formfiller.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'examples') diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 041c6a6..19147a8 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -41,6 +41,7 @@ DMENU_ARGS="-i" DMENU_SCHEMA="formfiller" DMENU_LINES="3" DMENU_PROMPT="Choose profile" +DMENU_OPTIONS="vertical resize" source $UZBL_UTIL_DIR/dmenu.sh source $UZBL_UTIL_DIR/editor.sh -- cgit v1.2.3