Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [2022] system tray icon missing when running as root

[2022] system tray icon missing when running as root

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 619 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nagendra NR
    wrote on last edited by
    #1

    Re: system tray icon missing when running as root

    Hi All,

    I have an application which needs to be run as root on linux and i am still facing this issue. Is there any fix identified ?

    PS : Its the issue only with SystemTray icon , and other GUI components are working fine. I am getting following warning as well in the console

    QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 1000
    QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 1000
    

    I am using Qt 6.3.

    thanks,
    -Nagendra N.R.

    JonBJ 1 Reply Last reply
    0
    • N Nagendra NR

      Re: system tray icon missing when running as root

      Hi All,

      I have an application which needs to be run as root on linux and i am still facing this issue. Is there any fix identified ?

      PS : Its the issue only with SystemTray icon , and other GUI components are working fine. I am getting following warning as well in the console

      QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 1000
      QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 1000
      

      I am using Qt 6.3.

      thanks,
      -Nagendra N.R.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Nagendra-NR
      You are UID 1000. Root is UID 0. The error comes from https://code.woboq.org/qt6/qtbase/src/corelib/io/qstandardpaths_unix.cpp.html#186. It is complaining that your "XdgRuntimeDir" is owned by you, but running a UI program as root means it tries to access/write to it as root, which it does not allow.

      In order to get past this, if you run a UI program as root while logged into the windowing system as you/a non-root user you will need to: look at your environment variables. You will see XDG_RUNTIME_DIR=/run/user/1000. You need to change that to XDG_RUNTIME_DIR=/run/user/0 to run your program. That should get you past that error message. Whether it will work elsewhere/for other checks I cannot say.

      As I commented in the thread you reference: why do you need to run a UI program as root? It is a bad idea, and you may face other problems.

      1 Reply Last reply
      2
      • N Offline
        N Offline
        Nagendra NR
        wrote on last edited by
        #3

        @JonB said in [2022] system tray icon missing when running as root:

        Thanks @JonB for the reply. I was running "sudo -E ./my_application " as a normal user to start the application. That warning is not coming when i directly run as root. But the original issue still remains, which is, SystemTray not getting displayed when run as root where other GUI components are fine.

        JonBJ 1 Reply Last reply
        0
        • N Nagendra NR

          @JonB said in [2022] system tray icon missing when running as root:

          Thanks @JonB for the reply. I was running "sudo -E ./my_application " as a normal user to start the application. That warning is not coming when i directly run as root. But the original issue still remains, which is, SystemTray not getting displayed when run as root where other GUI components are fine.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Nagendra-NR said in [2022] system tray icon missing when running as root:

          I was running "sudo -E ./my_application " as a normal user to start the application. That warning is not coming when i directly run as root

          That would make sense then. If you want to do -E you would need to change that environment variable, or don't use -E.

          SystemTray not getting displayed when run as root where other GUI components are fine.

          So maybe the system tray cannot "mix" existing icons for desktop user with new icons for a different user (root) who is not the desktop user. No idea.

          As I commented in the thread you reference: why do you need to run a UI program as root? It is a bad idea, and you may face other problems.

          You did not respond to this. X-org etc. do not like root running UIs, or not when the desktop is under another user. Nearly every time we have asked this question it transpires that running the Qt UI application as root is not a good idea and there is an alternative.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved