From a8fbcb6165fad4305e82bcda566e0118fa843275 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 30 Oct 2013 19:48:12 -0200 Subject: [PATCH] Add Launch{Browser,Market,Email} support on Linux Modern Linux desktop should implement a xdg-open program, that should open an URL on the default desktop program. The documentation of xdg-open says that we should supply xdg-open script on our installation script for fallback purposes, but I don't think this is really necessary: anyone using a reasonable recently DE on Linux should have xdg-utils installed. --- base/PCMain.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/base/PCMain.cpp b/base/PCMain.cpp index de8be6db13..338316a57b 100644 --- a/base/PCMain.cpp +++ b/base/PCMain.cpp @@ -11,6 +11,7 @@ #else #include #include +#include #endif #include @@ -228,6 +229,9 @@ void LaunchBrowser(const char *url) { #ifdef _WIN32 ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); +#elif __linux__ + std::string command = std::string("xdg-open ") + url; + system(command.c_str()); #else ILOG("Would have gone to %s but LaunchBrowser is not implemented on this platform", url); #endif @@ -237,6 +241,9 @@ void LaunchMarket(const char *url) { #ifdef _WIN32 ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); +#elif __linux__ + std::string command = std::string("xdg-open ") + url; + system(command.c_str()); #else ILOG("Would have gone to %s but LaunchMarket is not implemented on this platform", url); #endif @@ -246,6 +253,9 @@ void LaunchEmail(const char *email_address) { #ifdef _WIN32 ShellExecute(NULL, "open", (std::string("mailto:") + email_address).c_str(), NULL, NULL, SW_SHOWNORMAL); +#elif __linux__ + std::string command = std::string("xdg-open mailto:") + email_address; + system(command.c_str()); #else ILOG("Would have opened your email client for %s but LaunchEmail is not implemented on this platform", email_address); #endif