#!/bin/bash
# opens luakit, updating the adblock easylist.txt if needed and available...
bfile="$HOME/.local/share/luakit/adblock/easylist.txt"

if [ -f "$bfile" ]; then
	if [[ $(find "$bfile" -mtime +4 -print) ]]; then
		Xdialog  --icon /usr/share/pixmaps/adblock.xpm --title "Ablock Update" --infobox "Attempting to update Ablock block list" 0 0 3000&
		wget -O "$bfile" "https://easylist.to/easylist/easylist.txt"
		if [ $? -ne 0 ]; then
			Xdialog  --icon /usr/share/pixmaps/adblock.xpm --title "Ablock Update" --infobox "Cannot download updated AD blocklist at this time...\nwill try again the next time you open luakit :-)" 0 0 6000
		fi
	fi
fi
if [ -z "$1" ]; then
	luakit
else
	luakit "$1"
fi


