Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 1836  / 1 Year ago, wed, march 22, 2023, 4:48:10

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.


More From » kubuntu

 Answers
7

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.


[#3099] Thursday, March 23, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
doredtness

Total Points: 153
Total Questions: 113
Total Answers: 106

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
doredtness questions
Tue, Aug 2, 22, 15:45, 2 Years ago
Sat, May 21, 22, 05:26, 2 Years ago
Wed, Aug 24, 22, 11:09, 2 Years ago
;