use xdg-open to open url on Linux

This commit is contained in:
Thomas Debesse 2017-07-11 05:36:00 +02:00 committed by Garux
parent 4b2f9d6080
commit edb9abc546

View File

@ -35,11 +35,9 @@ bool open_url( const char* url ){
#if defined( __linux__ ) || defined( __FreeBSD__ ) #if defined( __linux__ ) || defined( __FreeBSD__ )
#include <stdlib.h> #include <stdlib.h>
bool open_url( const char* url ){ bool open_url( const char* url ){
// \todo FIXME: the way we open URLs on *nix should be improved. A script is good (see how I do on RTCW)
//Fedora 25: Help > Manual leads to "sh: firefox: command not found" error on terminal, while xdg-open http://some/url/ works just fine (and opens up the URL in the web browser)
char command[2 * PATH_MAX]; char command[2 * PATH_MAX];
snprintf( command, sizeof( command ), snprintf( command, sizeof( command ),
"firefox -remote \"openURL(%s,new-window)\" || firefox \"%s\" &", url, url ); "xdg-open \"%s\" &", url );
return system( command ) == 0; return system( command ) == 0;
} }
#endif #endif