Launching Libertine Application from an other QML C++ application
-
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 worksThe 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 -
@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.
-
@ikoz Yes It does work but not perfectly
-
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 withlomiri-app-launch-appids
. Libertine appids start with their container id. -
@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
-
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 regardinglibertine-launch
thelomiri-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(); }
-
@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
-
@kazord the worker is probably not any more useful, anyway it is not launch in a separate thread anymore.
If I removelibertineProcess.waitForFinished(-1);
the process is immediacy killedNov 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.