From f41cc7d6444c635d6ec069e8eaad6d05028d1fd6 Mon Sep 17 00:00:00 2001 From: Ev1lbl0w Date: Sat, 24 Oct 2020 16:54:24 +0100 Subject: [PATCH] Changed shell_open behaviour (cherry picked from commit 9e57a395cf2a093f273c4f10e16f224d2c7f2ddd) --- platform/x11/os_x11.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 8703251697..b434f17cd3 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -2924,18 +2924,40 @@ String OS_X11::get_name() const { } Error OS_X11::shell_open(String p_uri) { - Error ok; + int err_code; List args; args.push_back(p_uri); - ok = execute("xdg-open", args, false); - if (ok == OK) + + // Agnostic + ok = execute("xdg-open", args, true, NULL, NULL, &err_code); + if (ok == OK && !err_code) { return OK; - ok = execute("gnome-open", args, false); - if (ok == OK) + } else if (err_code == 2) { + return ERR_FILE_NOT_FOUND; + } + // GNOME + args.push_front("open"); // The command is `gio open`, so we need to add it to args + ok = execute("gio", args, true, NULL, NULL, &err_code); + if (ok == OK && !err_code) { return OK; - ok = execute("kde-open", args, false); - return ok; + } else if (err_code == 2) { + return ERR_FILE_NOT_FOUND; + } + args.pop_front(); + ok = execute("gvfs-open", args, true, NULL, NULL, &err_code); + if (ok == OK && !err_code) { + return OK; + } else if (err_code == 2) { + return ERR_FILE_NOT_FOUND; + } + // KDE + ok = execute("kde-open5", args, true, NULL, NULL, &err_code); + if (ok == OK && !err_code) { + return OK; + } + ok = execute("kde-open", args, true, NULL, NULL, &err_code); + return !err_code ? ok : FAILED; } bool OS_X11::_check_internal_feature_support(const String &p_feature) {