Trying to run X app Rocky 10 wayland

I have installed UPSmart UPS monitoring software on my Rocky 10 server.

It is an X application so initially fails to run with “cannot connect to X server”.

Mr Google suggested using “QT_QPA_PLATFORM=xcb UPSmart”.

The first time I tried this it worked but when I tried again three minutes later, it failed with the same X server error.

All subsequent tries also failed, even after logging out and in again.

Why would it work once but not again?

I guess I’m less interested in why it worked just once than why I can’t get it to work now.

Is the QT_QPA_PLATFORM bit the only way to get an x program to work on Rocky 10?

Any way to get more information on the failure?

Do any of these google results help? Google Search

Some of them suggest running the apps with xwayland. Others suggest some apps can have problems if they are requring root privileges. There’s this one that also suggests running a specific wayland process, and then running a window compositor like openbox to then launch the app that you want to run: Run buggy X11 apps with Xwayland rootful mode

It may also be worth asking the devs of the UPSmart software how to run their app on wayland, as I expect they’ve encountered it before now most likely.

Thank you very much.
Your Google search results were a gold mine.

Both “unset WAYLAND_DISPLAY” and “GDK_BACKEND=x11 your_gtk_app_command”
get the program running.
The gotcha is that it only works for a normal user; not for root.
Running as a normal user the program looks to be running properly but it
cannot open the USB-connected UPS; presumably because of permissions.
Trying as root, it still fails with the cannot connect to X error.

I’ll keep digging.

Got it!

Apparently Rocky 10 has rules on root use of wayland/xwayland.

To get around these I first export GDK_BACKEND=x11 then run the program via sudo.

Another way to get it running as a normal user, would be to connect it via usb, check dmesg, to see what /dev/usb device or whatever it appeared as, and then check the permissions on that /dev/whatever. You can then add the user to the group of that device. I usually do this when I connect my USB serial cable so that I don’t have to run minicom as root.

But your sudo option is fine also as it saves having to do all that. But you could do the above if you didn’t want to use sudo.