[PC-BSD Commits] r12385 - pcbsd/current/src-sh/pc-su

svn at pcbsd.org svn at pcbsd.org
Mon Aug 29 11:34:45 PDT 2011


Author: kris
Date: 2011-08-29 11:34:45 -0700 (Mon, 29 Aug 2011)
New Revision: 12385

Modified:
   pcbsd/current/src-sh/pc-su/pc-su
Log:

Enhance pc-su to use the right su backend depending upon which WM you are running



Modified: pcbsd/current/src-sh/pc-su/pc-su
===================================================================
--- pcbsd/current/src-sh/pc-su/pc-su	2011-08-29 18:30:38 UTC (rev 12384)
+++ pcbsd/current/src-sh/pc-su/pc-su	2011-08-29 18:34:45 UTC (rev 12385)
@@ -2,20 +2,49 @@
 # Wrapper script which finds the right "su" program
 # to use for graphical root execution
 
+# Figure out which file explorer to use based upon desktop
+if [ "$KDE_FULL_SESSION" = "true" ]; then DE=KDE;
+elif [ ! -z "$GNOME_DESKTOP_SESSION_ID" ]; then DE=GNOME;
+elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=GNOME;
+elif [ "$XDG_MENU_PREFIX" = "xfce-" ] ; then DE=XFCE;
+elif [ "$DESKTOP_SESSION" = "LXDE" ]; then DE=LXDE;
+else DE=""; fi
+
+case $DE in
+   KDE) SUP="kdesu" ;;
+ GNOME) SUP="gksu" ;;
+  XFCE) SUP="gksu" ;;
+  LXDE) SUP="gksu" ;;
+     *) # Unknown WM, try some common FE
+        SUP="gksu" ;;
+esac
+
 if [ `id -r -u` != "0" ] ; then
 	VARS="`echo $@`"
-
-        # Find the right "su" program to use
-        which kdesu >/dev/null 2>/dev/null
-        if [ "$?" = "0" ] ; then
+	
+	if [ "$SUP" = "kdesu" ] ; then
+          which kdesu >/dev/null 2>/dev/null
+          if [ "$?" = "0" ] ; then
                 kdesu -t -c "$VARS"
                 exit $? 
-        fi
-        which gksu >/dev/null 2>/dev/null
-        if [ "$?" = "0" ] ; then
+          fi
+          which gksu >/dev/null 2>/dev/null
+          if [ "$?" = "0" ] ; then
                 gksu -a "$VARS"
                 exit $? 
-        fi
+          fi
+	else
+          which gksu >/dev/null 2>/dev/null
+          if [ "$?" = "0" ] ; then
+                gksu -a "$VARS"
+                exit $? 
+          fi
+          which kdesu >/dev/null 2>/dev/null
+          if [ "$?" = "0" ] ; then
+                kdesu -t -c "$VARS"
+                exit $? 
+          fi
+	fi
 	
 	# If no utility could be found...
 	echo "No graphical switch-user utility found!"



More information about the Commits mailing list