Skip to content

Commit b6457c8

Browse files
committed
_webui_custom_browser_exist - Linux
1 parent 8d9c6b2 commit b6457c8

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

src/webui.c

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5843,9 +5843,56 @@ static bool _webui_custom_browser_exist(_webui_window_t* win, size_t browser) {
58435843
// `Chromium.app`...
58445844
// `Firefox.app`...
58455845
#else
5846-
// TODO: Custom browser path Linux
5847-
// `google-chrome`...
5848-
// `firefox`...
5846+
#define MAX_BROWSER_FILES (2)
5847+
char* executable = NULL;
5848+
char* executables[MAX_BROWSER_FILES] = {0};
5849+
if (browser == Chrome) {
5850+
executables[0] = "google-chrome";
5851+
executables[1] = "google-chrome-stable";
5852+
}
5853+
else if (browser == Edge) {
5854+
executables[0] = "microsoft-edge-stable";
5855+
executables[1] = "microsoft-edge-beta";
5856+
}
5857+
else if (browser == Epic) {
5858+
executables[0] = "epic";
5859+
executables[1] = NULL;
5860+
}
5861+
else if (browser == Vivaldi) {
5862+
executables[0] = "vivaldi";
5863+
executables[1] = "vivaldi-stable";
5864+
}
5865+
else if (browser == Brave) {
5866+
executables[0] = "brave";
5867+
executables[1] = NULL;
5868+
}
5869+
else if (browser == Firefox) {
5870+
executables[0] = "firefox";
5871+
executables[1] = NULL;
5872+
}
5873+
else if (browser == Yandex) {
5874+
executables[0] = "yandex-browser";
5875+
executables[1] = NULL;
5876+
}
5877+
else if (browser == Chromium) {
5878+
executables[0] = "chromium-browser";
5879+
executables[1] = "chromium";
5880+
}
5881+
else return false;
5882+
if (_webui_folder_exist(_webui.custom_browser_folder_path)) {
5883+
char full_path[(WEBUI_MAX_PATH - 1)] = {0};
5884+
for (int i = 0; i < MAX_BROWSER_FILES && executables[i] != NULL; i++) {
5885+
WEBUI_SN_PRINTF_STATIC(
5886+
full_path, (WEBUI_MAX_PATH - 1),
5887+
"%s/%s", _webui.custom_browser_folder_path, executables[i]
5888+
);
5889+
if (_webui_file_exist(full_path)) {
5890+
// Browser Found
5891+
if(win) WEBUI_SN_PRINTF_DYN(win->browser_path, WEBUI_MAX_PATH, "\"%s\"", full_path);
5892+
return true;
5893+
}
5894+
}
5895+
}
58495896
#endif
58505897

58515898
return false;

0 commit comments

Comments
 (0)