#!/bin/sh

set -e

case "$1" in
    configure|triggered)
	#update-alternatives --install /usr/bin/x-session-manager \
    #lightdm-gtk-greeter-config-derivative \
    #/usr/share/ultimate_edition/lightdm-ultimate.conf 90
    if test "/etc/default/grub" >/dev/null 2>&1
    then
    	echo "Setting default grub theme to Ultimate Edition #VERSION"
    	QUOTE='"'
    	LOCATION="GRUB_THEME=\/boot\/grub\/themes\/Ultimate_Edition_#VERSION\/theme.txt"
    	BACKGROUND="\/usr\/share\/wallpapers\/Ultimate_Edition_#VERSION.png"
    	PICTURE="\/usr\/share\/wallpapers\/Ultimate_Edition_#VERSION.png"
   	    grep -qxF 'GRUB_THEME=/boot/grub/themes/Ultimate_Edition_#VERSION/theme.txt' /etc/default/grub | sed -i "s/^.*GRUB_THEME=.*/"${LOCATION}"/g" /etc/default/grub || echo 'GRUB_THEME=/boot/grub/themes/Ultimate_Edition_#VERSION/theme.txt' >> /etc/default/grub
   	    grep -qxF 'GRUB_BACKGROUND="/usr/share/wallpapers/Ultimate_Edition_#VERSION.png"' /etc/default/grub | sed -i "s/^.*GRUB_BACKGROUND=.*/GRUB_BACKGROUND="${QUOTE}${BACKGROUND}${QUOTE}"/g" /etc/default/grub || echo 'GRUB_BACKGROUND="/usr/share/wallpapers/Ultimate_Edition_#VERSION.png"' >> /etc/default/grub
   	    grep -qxF 'export GRUB_MENU_PICTURE="/usr/share/wallpapers/Ultimate_Edition_#VERSION.png"' /etc/default/grub | sed -i "s/^.*export GRUB_MENU_PICTURE=.*/export GRUB_MENU_PICTURE="${QUOTE}${PICTURE}${QUOTE}"/g" /etc/default/grub || echo 'export GRUB_MENU_PICTURE=="/usr/share/wallpapers/Ultimate_Edition_#VERSION.png"' >> /etc/default/grub
    fi
	#echo "Installing Group Ultimate"
	#echo >&2 "Adding ultimate user group ..."
	#getent group ultimate > /dev/null || groupadd -r ultimate
	#echo >&2 "Adding ultimate user account ..."
	#getent passwd ultimate > /dev/null || useradd -r -g ultimate -c ultimate -s /sbin/nologin -d / ultimate
	#echo "Done."

	if which update-initramfs >/dev/null 2>&1
	then
	    update-initramfs -u
	fi
	;;

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

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

#manually set layout and panels height
#gdm gconftool-2 --set --type string /desktop/gnome/peripherals/mouse/cursor_theme 'Ultimate Edition Blue Velvet Cursor'

exit 0
# ==============================================================================
# This code was automatically cleaned up using code-cleanup
# title			:code-cleanup
# description		:Bash code cleanup script
# Author		:root
# date			:10/23/2013
# version		:1.7.2-1
# http://ultimateedition.info/
# ==============================================================================
