| 79 | } |
| 80 | |
| 81 | std::string FindXDGOpen() |
| 82 | { |
| 83 | const char *path = getenv("PATH"); |
| 84 | |
| 85 | if (!path) |
| 86 | return {}; |
| 87 | |
| 88 | std::string result; |
| 89 | |
| 90 | while (*path) { |
| 91 | const char *colon = strchr(path, ':'); |
| 92 | if (!colon) |
| 93 | colon = path + strlen(path); |
| 94 | |
| 95 | result.assign(path, colon); |
| 96 | result += "/xdg-open"; |
| 97 | |
| 98 | if (access(result.c_str(), X_OK) == 0) |
| 99 | return result; |
| 100 | |
| 101 | path = colon; |
| 102 | |
| 103 | if (*path == ':') |
| 104 | ++path; |
| 105 | } |
| 106 | |
| 107 | return {}; |
| 108 | } |
| 109 | |
| 110 | bool RunXDGOpen(const std::string& uri) |
| 111 | { |