#!/bin/sh
# To start the MythTV frontend with proper seating and dbus support,
# when wdm is the display manager.  Also works under seat-aware 
# display managers like gdm and kdm; it bypasses those steps.

# Depending on what has and hasn't been done already, which depends on PAM
# configuration and idiosyncracies of the display manager, we build up a
# chain of nested commands in this variable.
command=

# Use ConsoleKit (ck-launch-session) if not set up by the display manager.
cklaunch=`which ck-launch-session`
if ck-list-sessions | grep "x11-display.*$DISPLAY" > /dev/null ; then
	:		# The display manager already registered the session
elif test -n "$cklaunch" -a "x$cklaunch" != "xno"; then
	command="$command $cklaunch"
fi


# Use dbus-launch if installed.
if test x"$DBUS_SESSION_BUS_ADDRESS" = x""; then
	dbuslaunch=`which dbus-launch`
	if test x"$dbuslaunch" != x"" -a x"$dbuslaunch" != x"no"; then
		command="$command $dbuslaunch --exit-with-session"
	fi
fi

command="$command mythfrontend"

exec $command
