Announcement

Collapse
No announcement yet.

icon tray copyq failure from root script

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [RESOLVED] icon tray copyq failure from root script

    I have a root script to sync my files on a pen-drive. This script is a root one, because I have to stop (at the beginning) and restart (at the end) a mariadb server (I can do this only as root).
    I have also to close (before syncing) and re-open (after syncing) copyq.
    So far (before switch to 22.04 lts, I have KDE Neon) this code worked:

    Code:
    sudo -u myusername env QT_QPA_PLATFORM=xcb copyq exit​
    and

    Code:
    sudo -u myusername env QT_QPA_PLATFORM=xcb copyq &​
    Now the second code doesn't work anymore: the error message is

    Code:
    QtWarning: env says KDE is running but SNI unavailable -- check KDE_FULL_SESSION and XDG_CURRENT_DESKTOP​
    Nothing to do, adding

    Code:
    export XDG_CURRENT_DESKTOP=KDE
    export KDE_FULL_SESSION=true​
    to my .bashrc.

    To sum up: no way to restart copyq as user in a root script.
    Any idea? A bug?

    Thank you!

    #2
    Does leaving out the env work? You might have to give the full path to copyq. Or, use bash -c
    Code:
    sudo -u myusername QT_QPA_PLATFORM=xcb bash -lc copyq &
    Regards, John Little

    Comment


      #3
      Even with your code I get the same error message:

      Code:
      [default] QtWarning: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '
      /tmp/runtime-duns'
      Warning: [kf.notifications] QtWarning: env says KDE is running but SNI unavailable -- check KDE_FULL_SES
      SION and XDG_CURRENT_DESKTOP
      Using "myusername" instead of my reale username (duns) I got this strange message (partly in Italian, I hope you understand):

      Code:
      sudo: unknown user myusername
      sudo: errore nell'inizializzare il plugin di audit sudoers_audit

      Comment


        #4
        But I noticed that the problem is not that the copyq server doesn't start, but only that the icon tray of copyq is not visible.

        EDIT

        Indeed with this code

        Code:
        sudo -u duns env QT_QPA_PLATFORM=xcb copyq --start-server show
        [1]+ Completato sudo -u duns QT_QPA_PLATFORM=xcb bash -lc copyq show
        I have the server working, and the main window visible, but not the icon tray.
        ​Therefore I have changed the title of this thread.

        EDIT

        There is a know bug about copyq icon tray: see https://github.com/hluk/CopyQ/issues/1973
        But in my case starting copyq as user I have tray icon. The only problem is starting user copyq from a root script.

        EDIT

        I have opened a bug report here.
        Last edited by jduns; Oct 28, 2022, 12:31 AM.

        Comment


          #5
          Today I was said to set the DBUS_SESSION_BUS_ADDRESS​ environment, but I don't know how.

          Comment


            #6
            Originally posted by jduns View Post
            Today I was said to set the DBUS_SESSION_BUS_ADDRESS​ environment, but I don't know how.
            It's tricky. See, f.ex., this post

            Setting environment variables in your existing script won't affect the command being run by sudo -u, so I suggest another script that has the dbus stuff, then runs copyq, and the sudo -u runs that; cleaner that way IMO. Otherwise, your script could find the variables and add them to the command, like the QT_QPA_PLATFORM is set.
            Regards, John Little

            Comment


              #7
              Thank you. I have solved! This code works:

              Code:
              sudo -u [myusername] env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus copyq --start-server​

              Comment

              Working...
              X