#!/bin/bash
#
# [Qt]SixA - The Sixaxis Joystick Manager
# last modified by falkTX - 05/10/2009
VERSION="1.2"

# NOTE - this file only exists because I still don't know how to do some things directly on python
#	This file is almost useless and it will be removed soon

# NOTE - I don't care about kdesu, it works as it is so...

######################################
# SWITCHES start

case "$1" in

   version|-version|--version|version|v|-v|--v)
echo "[Qt]SixA v$VERSION - Wrote by falkTX, 2009
Released under the terms of the GNU GPL v2 license"
	;;

  help|-help|--help|h|-h|--h)
echo "[Qt]SixA - The Sixaxis Joystick Manager

Usage: sixa [command]

Available Commands:
	h, help			Show help
	v, version		Show [Qt]SixA version

(Please note that pressing the PS button is all you need to connect a device.
To start the gui launch 'qtsixa')
"
	;;

  get-root)
KDESU='kdesu -- '
KDESUDO='kdesudo -i /usr/share/qtsixa/icons/qtsixa.png -- '
GKSU='gksu --description /usr/share/applications/qtsixa.desktop -- '

#taken from winetricks (modified):
if [ x"$KDE_FULL_SESSION" = x"true" ]; then
{ #KDE
    if [ -f /usr/bin/kdesudo ]; then ROOT="$KDESUDO"; else
      if [ -f /usr/bin/kdesu ]; then ROOT="$KDESU"; else
	if [ -f /usr/bin/gksu ]; then ROOT="$GKSU"; else
	  ROOT='sudo'
	fi
      fi
    fi
} #KDE (End)
else if [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then
{ #Gnome
    if [ -f /usr/bin/gksu ]; then ROOT="$GKSU"; else
      if [ -f /usr/bin/kdesudo ]; then ROOT="$KDESUDO"; else
	if [ -f /usr/bin/kdesu ]; then ROOT="$KDESU"; else
	  ROOT='sudo'
	fi
      fi
    fi
} #Gnome (End)
else if [ x"$DISPLAY" != x"" ]; then
{ #Other X
    if [ -f /usr/bin/gksu ]; then ROOT="$GKSU"; else
      if [ -f /usr/bin/kdesudo ]; then ROOT="$KDESUDO"; else
	if [ -f /usr/bin/kdesu ]; then ROOT="$KDESU"; else
	  ROOT='sudo'
	fi
      fi
    fi
} #Other X (End)
else
{ #No known session
    if [ -f /usr/bin/gksu ]; then ROOT="$GKSU"; else
      if [ -f /usr/bin/kdesudo ]; then ROOT="$KDESUDO"; else
	if [ -f /usr/bin/kdesu ]; then ROOT="$KDESU"; else
	  ROOT='sudo'
	fi
      fi
    fi
} #No known session (End)
fi
fi
fi

echo "$ROOT"
	;;


  *)
sixa --help
	;;

esac

# Switches End
##############################################
