post_install() {
	xdg-icon-resource forceupdate --theme hicolor &> /dev/null

	mime_line="application/postscript      application/vnd.cups-pdf 66  gstopdf"
	cups_conf='/etc/cups/local.convs'
	if [ -e $cups_conf ]; then
	    grep -q -F "$mime_line" $cups_conf || echo "$mime_line" >> $cups_conf
	else 
	    echo "$mime_line" > $cups_conf
	fi
	update-desktop-database -q
}

post_upgrade() {
	post_install
}

post_remove() {
	xdg-icon-resource forceupdate --theme hicolor &> /dev/null

	matches(){
	    input="$1"
	    pattern="$2"
	    echo "$input" | grep -q "$pattern"
	}
	
	# Uninstall printers
	files=`grep -l "kyofilter_H\|kyofilter_ras_H\|kyofilter_pdf_H\|kyofilter_kpsl_H" /etc/cups/ppd/* 2>/dev/null`
	if [ ! -z "$files" ]; then
		for file in ${files}; do
			if matches $file .ppd; then
				basefile=$(basename $file .ppd)
				lpadmin -x $basefile
			fi
		done
	fi

	#echo ""
	update-desktop-database -q
}
