You are not logged in.
Hello,
I'm trying to create a user service that would start OpenRGB (a Qt application) at startup with sudo. I need sudo for OpenRGB to detect all my devices.
However, the service always fails after startup...
It works as expected if I restart it from the terminal with "systemctl --user restart rgb" so I'm thinking it may be started too soon during the startup?
But it still fails when I add a "sleep 20" before the "sudo /usr/bin/openrgb" so it might be something else.
I'm using Gnome with Wayland.
The service status after startup:
[ginko@PC ~]$ systemctl --user status rgb
× rgb.service - OpenRGB
Loaded: loaded (/home/ginko/.config/systemd/user/rgb.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sun 2024-09-01 10:32:03 CEST; 14s ago
Duration: 2.481s
Invocation: 3a2d8e1e07894beba5c450dfe8f9dbac
Process: 918 ExecStart=/home/ginko/Scripts/OpenRGB.sh (code=exited, status=134)
Main PID: 918 (code=exited, status=134)
Mem peak: 24.5M
CPU: 94ms
Sep 01 10:32:01 PC systemd[897]: Starting OpenRGB...
Sep 01 10:32:01 PC systemd[897]: Started OpenRGB.
Sep 01 10:32:01 PC sudo[929]: pam_systemd_home(sudo:account): New sd-bus connection (system-bus-pam-systemd-home-929) opened.
Sep 01 10:32:01 PC sudo[929]: ginko : PWD=/home/ginko ; USER=root ; COMMAND=/usr/bin/openrgb --gui --noautoconnect --startminimized --brightness 0
Sep 01 10:32:01 PC sudo[929]: pam_unix(sudo:session): session opened for user root(uid=0) by ginko(uid=1000)
Sep 01 10:32:03 PC sudo[929]: pam_unix(sudo:session): session closed for user root
Sep 01 10:32:03 PC OpenRGB.sh[918]: /home/ginko/Scripts/OpenRGB.sh: line 4: 929 Aborted sudo /usr/bin/openrgb --gui --noautoconnect --startminimized --brightness 0
Sep 01 10:32:03 PC systemd[897]: rgb.service: Main process exited, code=exited, status=134/n/a
Sep 01 10:32:03 PC systemd[897]: rgb.service: Failed with result 'exit-code'.
From journalctl:
Sep 01 10:32:03 PC openrgb[936]: qt.qpa.xcb: could not connect to display
Sep 01 10:32:03 PC openrgb[936]: qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
Sep 01 10:32:03 PC openrgb[936]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
The OpenRGB.sh script (I tried to put something that waits for Wayland but no luck...):
#!/bin/bash
# We wait for wayland display and we start OpenRGB
while [[ $(systemctl --user show-environment | grep -q WAYLAND_DISPLAY) ]]; do sleep 1; done && sudo /usr/bin/openrgb --gui --noautoconnect --startminimized --brightness 0
The rgb.service:
[Unit]
Description=OpenRGB
PartOf=graphical-session.target
After=graphical-session.target
[Service]
Type=exec
ExecStart=%h/Scripts/OpenRGB.sh
[Install]
WantedBy=graphical-session.target
I also added this in sudoers:
%wheel ALL=(ALL:ALL) NOPASSWD:SETENV: /usr/bin/openrgb
The SETENV is here from when I tried to start OpenRGB with
sudo QT_QPA_PLATFORM=offscreen /usr/bin/openrgb
The service worked then, ps showed that OpenRGB is running but the gui was nowhere to be seen.
I should see the OpenRGB icon in my tray.
Anyone knows what is wrong with my service?
Last edited by Ginko (2024-09-01 16:10:04)
Offline
Do you have qt5-wayland installed?
Offline
I didn't so I tried installing it. The only difference is that the error message now lists more platform plugins :
Sep 01 11:17:55 PC openrgb[940]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
I tried adding these env variables in the sudo :
sudo QT_QPA_PLATFORM=wayland XDG_RUNTIME_DIR=/run/user/$(id -u ginko) /usr/bin/openrgb
And the service successfully starts after boot but the gui is still nowhere to be seen and OpenRGB doesn't appear in the tray:
Sep 01 11:27:32 PC openrgb[4069]: QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 1000
Sep 01 11:27:32 PC openrgb[4069]: QObject::connect: No such signal QPlatformNativeInterface::systemTrayWindowChanged(QScreen*)
And a service restart leads to the same result.
Offline
Why do you think you need to run OpenRGB (the GUI) as root? There's a system server component, you normally start that as root and then use the app as a normal user.
Last edited by V1del (2024-09-01 10:22:31)
Offline
Ah, you're right, it's so simple like that!
So I just shelved my script and am using this for the service now:
[Unit]
Description=OpenRGB
[Service]
Type=exec
ExecStart=sudo /usr/bin/openrgb --server --noautoconnect --brightness 0 --color 000000
[Install]
WantedBy=multi-user.target
And I just set up the GUI to start by ticking "Start At Login" in the OpenRGB options.
It connects to the server started by the service and all is well.
Thanks!
Offline
\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
As a rule of thumb: whenever you find yourself in the position of asking "how do I start this GUI client as root" -
STOP!
Take a step back and figure why you're trying to start a GUI client as root and where you made a mistake to come to that conclusion
Offline
I just did, and I will
Last edited by Ginko (2024-09-01 16:11:12)
Offline