User Tools

Site Tools


uzbl-extension-manager

Uzbl Extension Manager

Description

A simple extension manager for Uzbl. This will open files with extension ”.uzbl”.

Scripts

download-dot-uzbl.sh

#!/bin/sh
 
# Some sites block the default wget --user-agent..
GET="wget --user-agent=Firefox"
 
url="$8"
 
http_proxy="$9"
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 '^.*\.uzbl$' >/dev/null;
then
	( tmp=$(mktemp); $GET "$url" -O $tmp; $XDG_DATA_HOME/uzbl/scripts/uzbl-install.sh $tmp )
fi

uzbl-install.sh

#!/bin/sh
 
if [ -z $@ ]
then
	echo "Usage: uzbl-install *.uzbl.tar.gz"
	exit
fi
 
for a in $@
do
	TMP_DIRECTORY=$(mktemp -d)
	#mkdir -p $TMP_DIRECTORY
	case $(file -b --mime-type $a) in
		application/x-gzip)
			( tar xfz $a -C $TMP_DIRECTORY )
		;;
		application/
	esac
	NAME="$(cat $TMP_DIRECTORY/name)"
	EXTENSION_DIRECTORY="$XDG_DATA_HOME/uzbl/extensions"
	CONFIG_FILE="$XDG_CONFIG_HOME/uzbl/config"
	mkdir -p $EXTENSION_DIRECTORY/$NAME
 
	#cat $CONFIG_FILE > /tmp/uzbl-config
	#cat $TMP_DIRECTORY/config | sed "s|$EXTENSION_DIRECTORY/$NAME|$TMP_DIRECTORY/scripts|g" >> /tmp/uzbl-config
	#cat /tmp/uzbl-config | uzbl-core -c -
 
	installed=0
 
	if [ ! -z "$(grep "^$(cat $TMP_DIRECTORY/config | sed 's/\\/\\\\/g')$" $CONFIG_FILE)" ]
	then
		echo "Not appending to config file, extension appears to already be installed."
	else
		cat $TMP_DIRECTORY/config >> $CONFIG_FILE
	fi
 
	cp -r $TMP_DIRECTORY/* $EXTENSION_DIRECTORY/$NAME
 
	for f in $(ls "$EXTENSION_DIRECTORY/$NAME/scripts")
	do
		sed -n -e "s|\$XDG_DATA_HOME/uzbl/scripts|$EXTENSION_DIRECTORY/$NAME/scripts|g" "$EXTENSION_DIRECTORY/$NAME/scripts/$f"
	done
done

Installation

Copy both scripts to $XDG_DATA_HOME/uzbl/scripts/

Add this to your config file:

@on_event   DOWNLOAD_REQUEST    spawn $XDG_DATA_HOME/uzbl/scripts/download-dot-uzbl.sh %s \@proxy_url

Testing it

Making Uzbl Extensions

In the git repo there is a template Uzbl extension file, you can look there for more info.

Directory Structure:

  • ./version – Uzbl version to use with (in the format of “Commit: 1958b52d41cba96956dc1995660de49525ed1047”) obtained via “uzbl-core -V”
  • ./scripts/ – directory of scripts used in the extension
  • ./name – name of the extension
  • ./config – line of the config used to install it
uzbl-extension-manager.txt · Last modified: 2016/08/31 14:10 (external edit)