• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Launching Libertine Application from an other QML C++ application

Scheduled Pinned Locked Moved App Development
8 Posts 4 Posters 306 Views 1 Watching
Loading More Posts
  • 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.
    • S Offline
      saveurlinux
      last edited by 7 Nov 2024, 19:06

      Hello, I'm currently working on the ‘Launcher modular’ application.
      Among other things, it's an application launcher that also lets you quickly view information such as the latest messages or calls received, or upcoming events.
      It also allows users to briefly view RSS feeds or their photo album.
      Among its features, I'm having trouble launching ‘Libertine’ applications, which currently don't work on the OpenStore version.

      I'm in the process of fixing it, but I'm wondering if the solution I've found is the right one?
      The way I proceed is as follows:

      I've created a serviceWorker in C++ which launches an Xwayland server and the ‘Libertine’ application in a separate thread from the main application using
      QProcess libertineProcess.start(‘libertine-launch’, arguments);`````
      This solution works

      The problems I'm having are as follows:

      • I don't know If the way I've done it is correct ?
      • I have to configure Launcher Modular so that it doesn't hang or else the Libertine application stops responding after a few seconds.
      • Stopping the Libertine application works, but the Xwayland application remains in the background and if I stop it, Launcher Modular also stops.

      If you want to see the implementation you can have a look there
      https://github.com/lutin11/launcher-modular/tree/feature/libertine/plugins/LibertineLauncher

      I K 2 Replies Last reply 7 Nov 2024, 20:39 Reply Quote 0
      • I Offline
        ikoz @saveurlinux
        last edited by 7 Nov 2024, 20:39

        @saveurlinux Does it work if it is launched on an async thread (from STL, or POSIX threads)? It shouldn't hang.
        I've had some problems with qprocess unable to run certain commands too.

        Unfortunately every app has its own different plugin to run commands e.g. UTT, snapz0r, uadblock and my icon changer app.

        May the source be with you

        S 1 Reply Last reply 7 Nov 2024, 21:00 Reply Quote 0
        • S Offline
          saveurlinux @ikoz
          last edited by 7 Nov 2024, 21:00

          @ikoz Yes It does work but not perfectly

          1 Reply Last reply Reply Quote 0
          • K Offline
            kugiigi
            last edited by 11 Nov 2024, 19:45

            You can probably use lomiri-app-launch. That's the one used to launch all apps in Lomiri as far as I know. You can list appids with lomiri-app-launch-appids. Libertine appids start with their container id.

            1 Reply Last reply Reply Quote 1
            • K Offline
              kazord @saveurlinux
              last edited by 13 Nov 2024, 17:45

              @saveurlinux it used to be a link click from the "Action" value of appinfo plugin.

              was something like this back in 16.10 before lomiri
              "application:///"+packagename+".desktop"

              You should be able to edit this line with the new system url that start container

              1 Reply Last reply Reply Quote 0
              • S Offline
                saveurlinux
                last edited by saveurlinux 13 Nov 2024, 22:33

                Thanks for your answers,
                @kazord your solution is the one I'm using to launch the apps that are not libertine ones, unfortunately it didn't work for libertine ones.
                @kugiigi regarding libertine-launch the lomiri-app-launch commands add some benefits:

                • I no more have to use a dedicated thread
                • I do not have to require 'Launcher Modular' to be always on.

                After some investigation, I realized that I do not have to launch myself Xwayland so I could remove this code.

                This is the current code:

                LibertineWorker::LibertineWorker(const QString &containerName, const QString &appName, QObject *parent)
                    : QObject(parent), m_containerName(containerName), m_appName(appName) {}
                
                void LibertineWorker::run() {
                        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
                        QString displayValue = env.value("DISPLAY", ":0");  // TODO set environement at launcher modular startup
                        env.insert("DISPLAY", displayValue);
                
                        QProcess libertineProcess;
                        libertineProcess.setProcessEnvironment(env);
                
                        libertineProcess.start("lomiri-app-launch", QStringList() << m_containerName + "_" + m_appName);
                
                        if (!libertineProcess.waitForStarted()) {
                            qDebug() << "Erreur : Failed to start application" << m_appName;
                        } else {
                            qDebug() << "Application " << m_appName << " starting into containers " << m_containerName;
                        }
                
                        // Wait for the app to finish, then stop XWayland
                        libertineProcess.waitForFinished(-1);// avoid the 30-second timeout
                
                        emit finished();
                }
                
                K 1 Reply Last reply 13 Nov 2024, 22:59 Reply Quote 0
                • K Offline
                  kazord @saveurlinux
                  last edited by kazord 13 Nov 2024, 22:59

                  @saveurlinux, i dont have any device to test lomiri-app-launch,
                  it's an async start command, isn't it ?
                  In that case you don't need to keep the worker (and waitForFinish /finished is not the end of the app but the start call only)

                  Does the code do what you want ? or is there anything not working as expected

                  S 1 Reply Last reply 13 Nov 2024, 23:08 Reply Quote 0
                  • S Offline
                    saveurlinux @kazord
                    last edited by 13 Nov 2024, 23:08

                    @kazord the worker is probably not any more useful, anyway it is not launch in a separate thread anymore.
                    If I remove libertineProcess.waitForFinished(-1);
                    the process is immediacy killed

                    Nov 14 00:03:23 ubuntu-phablet aa-exec[11123]: Application  "firefox"  starting into containers  "libert1"
                    Nov 14 00:03:23 ubuntu-phablet aa-exec[11123]: QProcess: Destroyed while process ("lomiri-app-launch") is still running.
                    Nov 14 00:04:24 ubuntu-phablet aa-exec[11123]: QObject::startTimer: Timers cannot be started from another thread
                    

                    The code does what I want, but it remains me some stuff before publishing the fix.

                    1 Reply Last reply Reply Quote 0
                    8 out of 8
                    • First post
                      8/8
                      Last post