What's the best practice to launch a desktop entry in plasmoid?

Yesterday I tried Plasma 6.5 Beta on my laptop. Everything works fine except one applet: USwitch - KDE Store . It reports

module "org.kde.plasma.private.quicklaunch" is not installed

Said module was imported in this file: package/contents/ui/main.qml · fdb573e4c03d73023f3555968a186c15d4233e8b · Jakub Lipiński / uswitch · GitLab

Turns out that the applet uses “Logic” from quicklaunch applet to launch desktop entry

    Logic {
        id: kRun
        
        function launch(desktopFile) {
            openUrl('file:' + desktopFile)
        }
    }

After digging through the repositories, I found that the quicklaunch applet was ported to plasma_add_applet macro, and no longer provides a “private” qml library for others to import

Then I’m curious to find out how do other plasmoids launch desktop entries, so I searched “launcher” on store.kde.org, but all I could find is

import org.kde.plasma.private.quicklaunch

(which is not available anymore in plasma 6.5), or

import org.kde.plasma.private.kicker

(which seems too complicated for what I need)

I also tried to search for “run command in plasmoid”, hope to workaround this by just

kde-open /path/to/entry.desktop

but got this answer:

you can’t do this straight out of qtquick/qml …

Looking into Plasma’s QML API docs, there’re just UI components, nothing about launching desktop entry or running command …

So I wonder what’s the best practice to launch a desktop entry in plasmoid? Do you really have to write a C++ module only to do this job?

I know some C++, but plasmoid with C++ modules can’t be installed from KNewStuff “Get New” dialog, and needs to be re-compiled every time plasma updates, which makes it not so convenient for users. I would like to avoid C++ modules in plasmoids if possible.

Looking at the MR, looks like quicklaunch is still exposed but in org.kde.plasma.quicklaunch instead.

Actually no, there is only /usr/lib/qt6/plugins/plasma/applets/org.kde.plasma.quicklaunch.so , which packs all the qml and the previous “private” library. If I try

import org.kde.plasma.quicklaunch

in my plasmoid, it would complaint that the module “is not installed”. Also it’s not inside /usr/lib/qt6/qml/ directory, which probably means that it was not intended to be imported by others…

You are right. Looks like it’s not org.kde.plasma.quicklaunch, it’s still present as org.kde.plasma.private.quicklaunch. I guess I was missing something about how it’s set up with plasma_add_applet.

The reason there’s only an .so file I believe is because porting to the new declarative registration also brings the benefit that the QML files are compiled to C++, so the end result is just a library. So that part is fine.

I built a clean session with kde-builder and I can call the relevant code just fine from an app built with it, though. The module comes from kdeplasma-addons, but just to be sure you do have it installed in your beta system?

I’m on Arch Linux and have the packages from kde-unstable repository installed, including kdeplasma-addons. The quicklaunch itself works fine, but errors out when I’m trying to import quicklaunch’s “private” library from other plasmoids

This seems to be the key part, since the widget is now only a single file it no longer installs the plugin separately?

6.4

/usr/lib/qt6/qml/org/kde/plasma/private/quicklaunch/kde-qmlmodule.version
/usr/lib/qt6/qml/org/kde/plasma/private/quicklaunch/libquicklaunchplugin.so
/usr/lib/qt6/qml/org/kde/plasma/private/quicklaunch/qmldir
/usr/lib/qt6/qml/org/kde/plasma/private/quicklaunch/quicklaunchplugin.qmltypes

6.5

/usr/lib/qt6/plugins/plasma/applets/org.kde.plasma.quicklaunch.so

Also if the Quicklaunch widget is added to the panel/desktop the third party widgets that depend on it start working again, probably because the libquicklaunchplugin becomes known to Plasma?

How did you make third party widgets work again? In my case, the “uswitch” plasmoid still won’t load even if I add Quicklaunch to the panel and restart plasmashell.

Need to change the import statement to the new namespace too

import plasma.applet.org.kde.plasma.quicklaunch

Just a workaround, I think the best option here would be to make quicklaunch plugin a separate thing, should I file a bug report about this?

For now I think I’ll copy the plugin to my repo and import it at runtime if the user builds it from source.

Edit: this is the widget where I was also using the quicklaunchplugin https://github.com/luisbocanegra/plasma-panel-spacer-extended

1 Like