3

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.

4

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.

| improve this answer | |
  • I have reported previously bug 1713313 with special parser script for policykit policy files... Thanks! I forgot this moment. – N0rbert Jun 29 at 20:12
2

Really there is some kind of hack to use pkexec instead of sudo to launch application without specific PolicyKit .policy file. We need to specify missed environment variables as shown below:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY kubuntu-driver-manager

Experimentally I discovered that it needs only one /usr/share/polkit-1/actions/org.freedesktop.policykit.policy file for operation.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.