Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appstream:/id URL handler #11

Closed
aleixpol opened this issue Oct 16, 2015 · 4 comments
Closed

appstream:/id URL handler #11

aleixpol opened this issue Oct 16, 2015 · 4 comments

Comments

@aleixpol
Copy link
Collaborator

It would be really useful to have such a URL handler so that if the user clicks a URL with "appstream:" scheme, he launches Discover/Gnome-Software/Whatever.

This could help a lot minimize the access barrier to the projects we offer since we'd be leveraging a cross-distro naming scheme, therefore not compromising when giving a package name (like it used to be done with apt:/).

@aleixpol
Copy link
Collaborator Author

This simple patch does the trick in Discover.

diff --git a/discover/main.cpp b/discover/main.cpp
index 66ba5a7..21bf164 100644
--- a/discover/main.cpp
+++ b/discover/main.cpp
@@ -50,6 +50,7 @@ int main(int argc, char** argv)
         parser.addOption(QCommandLineOption("category", i18n("Display a list of entries with a category."), "name"));
         parser.addOption(QCommandLineOption("mode", i18n("Open Muon Discover in a said mode. Modes correspond to the toolbar buttons."), "name"));
         parser.addOption(QCommandLineOption("listmodes", i18n("List all the available modes.")));
+        parser.addPositionalArgument("urls", i18n("Supports appstream: url scheme"));
         MuonBackendsFactory::setupCommandLine(&parser);
         about.setupCommandLine(&parser);parser.addHelpOption();
         parser.addVersionOption();
@@ -74,6 +75,13 @@ int main(int argc, char** argv)
                 fprintf(stdout, " * %s\n", qPrintable(mode));
             return 0;
         }
+
+        foreach(const QString &arg, parser.positionalArguments()) {
+            QUrl url(arg);
+            if (url.scheme() == QLatin1String("appstream")) {
+                mainWindow->openApplication(url.path());
+            }
+        }
     }

     mainWindow->show();
diff --git a/discover/org.kde.discover.desktop b/discover/org.kde.discover.desktop
index d540f1b..be9128d 100644
--- a/discover/org.kde.discover.desktop
+++ b/discover/org.kde.discover.desktop
@@ -44,7 +44,8 @@ Name[uk]=Шукач Muon
 Name[x-test]=xxMuon Discoverxx
 Name[zh_CN]=Muon 发现者
 Name[zh_TW]=Muon 探詢器
-Exec=muon-discover
+MimeType=x-scheme-handler/appstream
+Exec=muon-discover %U
 Icon=muondiscover
 Type=Application
 X-DocPath=muon/index.html

@aleixpol
Copy link
Collaborator Author

@ximion
Copy link
Owner

ximion commented Oct 23, 2015

Will be in the next release, as discussed on IRC :-)
Thanks for reporting this!

@ximion ximion closed this as completed in 40ec324 Nov 3, 2015
@ximion
Copy link
Owner

ximion commented Nov 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants