#!/bin/sh
# postinst script for #PACKAGE#

set -e

case "$1" in
    configure)
	## xdg ##
	if [ -e /etc/xdg/kcm-about-distrorc ]; then
	    mv /etc/xdg/kcm-about-distrorc /etc/xdg/kcm-about-distrorc.dpkg.new
	fi
	cp -af /usr/share/tuxedo/kcm-about-distrorc /etc/xdg/
	
	if [ -e /etc/skel/.face ]; then
	    mv /etc/skel/.face /etc/skel/.face.dpkg.new
	fi
	if [ -h /etc/skel/.face.icon ]; then
	    rm /etc/skel/.face.icon
	fi
	    cp -af /usr/share/tuxedo/.face.icon /etc/skel/.face
	    ln -s /etc/skel/.face /etc/skel/.face.icon
	if [ -d /etc/skel/.local/share/kactivitymanagerd ]; then
	    rm -rf /etc/skel/.local/share/kactivitymanagerd
	fi
	if [ -e /usr/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/config/main.xml ]; then
	    sed -i 's/default>preferred.*/default>preferred:\/\/browser,applications:tuxedo-control-center.desktop,applications:tuxedo-webfai-creator.desktop,org.kde.plasma-systemmonitor.desktop,org.kde.konsole.desktop,systemsettings.desktop,org.kde.dolphin.desktop,org.kde.discover.desktop<\/default>/' /usr/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/config/main.xml
	fi
#	if [ -e /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/main.xml ]; then
#	    mv /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/main.xml /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/main.xml.dist
#	    cp -af /usr/share/tuxedo/main.xml /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/
#	fi
	if [ ! -f /usr/share/desktop-directories/TUXEDO.directory ]; then
	    if [ -f /usr/share/applications/tuxedo-webfai-creator.desktop ]; then
		xdg-desktop-menu install --novendor /usr/share/tuxedo/TUXEDO.directory  /usr/share/applications/tuxedo-webfai-creator.desktop
	    fi
	    if [ -f /usr/share/applications/tuxedo-control-center.desktop ]; then
		xdg-desktop-menu install --novendor /usr/share/tuxedo/TUXEDO.directory /usr/share/applications/tuxedo-control-center.desktop
	    fi
	fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

exit 0
