Skip to content

Draft: snap: use the PrivilegedDesktopLauncher dbus

This allow us to run the snaps from within a confined environment. This is meant to be a better and cleaner alternative to !873 (merged). This uses the io.snapcraft.Launcher dbus which is also used by the Ubuntu's new flutter based App Center. What I essentially wanted is to have something like this

void SnapResource::invokeApplication() const
{
    QDBusInterface interface(
        QStringLiteral("io.snapcraft.Launcher"),
        QStringLiteral("/io/snapcraft/PrivilegedDesktopLauncher"),
        QStringLiteral("io.snapcraft.PrivilegedDesktopLauncher"),
        QDBusConnection::sessionBus()
    );
    QString appName;
    for (int i = 0; i < m_snap->appCount(); i++){
        if (m_snap->app(i)->name().toLower() == m_snap->name())
        {
            appName = m_snap->app(i)->name();
        }
    }
    if (appName != QChar::Null){
        interface.call(
            QStringLiteral("OpenDesktopEntry"), QStringLiteral("%1_%2.desktop").arg(packageName(), appName)
        );
    }
}

But, I guess this is a bug in the snapd-glib api that m_snap->appCount() often returns empty list. Which is also mentioned by @daspood here

Merge request reports