#! /bin/sh
#
# QtParted Launcher
#
# This little script will execute QtParted with administrator privilegies
# It will try to autodetect which application should be used to gain
# those, choosing between kdesu, kdesudo and gksudo.
#
# By Siegfried-A. Gevatter <rainct@ubuntu.com>
# Licensed under the GNU General Public License, version 2 or later
# See '/usr/share/common-licenses/GPL' for more information.
#

if [ $(id -u) = 0 ]; then
	exec /usr/sbin/qtparted
fi

auth=""

if [ -x /usr/bin/kdesudo ]; then
	auth="/usr/bin/kdesudo"
elif [ -x /usr/bin/kdesu ]; then
	auth="/usr/bin/kdesu"
fi

if [ -z $auth ]; then
	if [ -x /usr/bin/gksudo ]; then
		auth="/usr/bin/gksudo"
	elif [ -x /usr/bin/gksu ]; then
		auth="/usr/bin/gksu"
	fi
fi

if [ -z $auth ]; then
	xmessage "Warning: Couldn't find any way to obtain sudo privilegies."
fi

exec $auth /usr/sbin/qtparted
