Previously it was told that it is bad idea to use sudo
to launch GUI-based applications.
So one should use pkexec
instead.
I remembered it, so I tried this to launch Kubuntu Driver Manager on Kubuntu 20.04 LTS using terminal as
pkexec kubuntu-driver-manager
But this command does not work, it crashes with the following output:
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: wayland-org.kde.kwin.qpa, dxcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Aborted (core dumped)
I have recently reported bug 1885615. But I'm very surprised with this behavior. And what is interesting sudo kubuntu-driver-manager
works normally.
I still can launch Gtk-based applications on Kubuntu using pkexec
- commands like pkexec pluma
results in opening the application with root rights.
So my question is in the title.
Really there is some kind of hack to use
pkexec
instead ofsudo
to launch application without specific PolicyKit .policy file. We need to specify missed environment variables as shown below:Experimentally I discovered that it needs only one
/usr/share/polkit-1/actions/org.freedesktop.policykit.policy
file for operation.To launch a program with
pkexec
a proper.policy
file for that program needs to be present in the/usr/share/polkit-1/actions
directory. It has nothing to do with which graphical toolkit (Gtk or Qt) is used.