#!/bin/bash

. ${TOOLKIT}-functions.sh


# (MAIN)

# fix bug on 10.* (others too?)
#
[ -f /etc/X11/xinit/xinitrc ] && chmod a+rx /etc/X11/xinit/xinitrc

case $DISTRIB_ID in
  Ubuntu)
	# apparmor, install default customizable files
	#
	for file in $(cd apparmor-local; ls)
	do
		[ -e /etc/apparmor.d/local/$file ] || {
			installfile apparmor-local/$file /etc/apparmor.d/local/ root:root 640
		}
		[ -f /etc/apparmor.d/$file ] && {
			echo "  reloading apparmor profile for $file"
			/sbin/apparmor_parser --replace -W /etc/apparmor.d/$file
		}
	done
	;;
esac

# evince replacement?
#
is_installed qpdfview && {
	[ -f /usr/bin/evince ] || {
		cd /usr/bin
		echo "  evince alterative: ln -s qpdfview evince"
		ln -s qpdfview evince
	}
}
for cmd in /usr/bin/qpdfview /usr/bin/evince
do
	[ -f $cmd ] && {
		echo "  pdf: setting '$cmd' as viewer in /etc/alternatives"
		update-alternatives --install /usr/bin/pdf pdf $cmd 20
		update-alternatives --install /usr/bin/pdfviewer pdfviewer $cmd 20
		update-alternatives --install /usr/bin/pdfreader pdfreader $cmd 20
		break
	}
done

##$SOMETHING_CHANGED && {
##}

exit 0
