Well, you could use kdesu in GNOME as well…
But as I already wrote:
For other desktops xdg-su uses gnomesu, or even “su -” directly. So this would not work in that case.
You could use “sudo” directly, as I wrote as well:
PS: you can run the GUI version of YaST via sudo as well, but by default sudo doesn’t pass the necessary environment variables ($DISPLAY e.g.). You can change that via settings in sudoers as well, see env_reset and/or env_keep in particular. Or pass $DISPLAY explicitely by running e.g. “sudo DISPLAY=:0 yast2”. And you’d also have to allow root to connect to your Xsession via xhost.
It should be possible to use “pkexec” to run YaST as root and change the polkit rules accordingly to not require a password, but for some reason I cannot get this to open a YaST GUI (it runs in text mode instead).
The problem is this (from “man pkexec”):
The environment that PROGRAM will run it, will be set to a minimal known and safe environment in order to avoid injecting code through
LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID
environment variable is set to the user id of the process invoking
pkexec. As a result, pkexec will not by default allow you to run X11
applications as another user since the $DISPLAY and $XAUTHORITY
environment variables are not set. These two variables will be retained
if the org.freedesktop.policykit.exec.allow_gui annotation on an action
is set to a nonempty value; this is discouraged, though, and should only
be used for legacy programs.
I have no idea how you would set the “freedesktop.policykit.exec.allow_gui annotation on an action” though.
Apparently you would need to create a file in /usr/share/polkit-1/actions/ similar to this one:
https://wiki.archlinux.org/index.php/Polkit#Actions
I just tried it and it works.
So, create a file /usr/share/polkit-1/actions/org.opensuse.pkexec.yast2.policy with the following content:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
<policyconfig>
<action id="org.opensuse.pkexec.yast2">
<message>Authentication is required to run YaST2</message>
<icon_name>yast2</icon_name>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/yast2</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
And you should be able to run YaST without password via:
pkexec yast2
and also “pkexec yast2 sw_single” or similar will work.
And this should work with all desktop environments.