system tray icon missing when running as root

  • Hi everybody,

    I have a tiny application that I need to have running as root (it controls a systemd service). It does not have any 'proper' window, but only lives in the system tray with context menu. If I run it as normal user, then the system tray icon shows up just fine. However, if I run it as root (typically by using kdesu), then nothing shows up in the system tray (though the application is running). I would assume that this is by design, but I also know that there are applications out there that successfully do something along these lines... What is the proper way to handle this scenario?


  • Lifetime Qt Champion


    Quick idea: run your application as standard user and ask for the credentials when you actually need it.

  • Hi,

    It is typically a bad Idea to run applications with root privileges. I have a similar setup from a php Minecraft configuration script that needs to read write and execute code as other users as well as run root privileged system commands. What I did was utilized sudo to handle this. You can configure all sorts of access and privileges from within /etc/sudoers for a more automatic under hood approach. The sudoers man pages should be able to help you out in this type of setup.


  • Thanks @SGaist and @Chrisw01! I now do it using sudo, it works just fine...

  • Lifetime Qt Champion


    Then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

  • Well, I was considering that. However, the initial problem isn't actually solved, I just ended up doing it differently. So, marking it as "Solved" might be misleading to others searching for this problem...

  • Lifetime Qt Champion

    I'd say yes and no. Having an application running permanently as root in a user session is pretty dangerous therefor having implemented it as a normal application requesting for elevated rights when needed is a better solution and solves the problem at hand even if it can be seen as a workaround for that specific part.

  • Good point, marked thread as solved...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.