diff --git a/README.md b/README.md index 44a00558..e7fae58c 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,9 @@ Latest release version: https://github.com/uowuo/abaddon/releases/latest The two folders within the `res` folder (`res/res` and `res/css`) are necessary. Windows also uses the `fonts` folder. You can put them directly next to the executable. On Linux, `css` and `res` can also be loaded from -`~/.local/share/abaddon` or `/usr/share/abaddon` +`~/.local/share/abaddon` or `/usr/share/abaddon`. On macOS, when installed via package managers +such as Homebrew, the install prefix (e.g. `/usr/local/share/abaddon` or the Homebrew Cellar location) +is also checked for resources. `abaddon.ini` will also be automatically used if located at `~/.config/abaddon/abaddon.ini` and there is no `abaddon.ini` in the working directory diff --git a/src/platform.cpp b/src/platform.cpp index 726655be..d43e0562 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -7,9 +7,7 @@ #ifdef __APPLE__ #include #endif -#ifdef __linux__ - #include "util.hpp" -#endif +#include "util.hpp" #include @@ -176,9 +174,20 @@ std::string Platform::FindResourceFolder() { if (resourceURL != NULL) { CFRelease(resourceURL); } - found_path = resourcePath; - found = true; - return found_path; + } + + // Fall back to cwd, user dir or install prefix (e.g. Homebrew installs into share/abaddon) + const auto home_env = std::getenv("HOME"); + if (home_env != nullptr) { + const static std::string home_path = std::string(home_env) + "/.local/share/abaddon"; + + for (const auto &path : {std::string(resourcePath), "."s, home_path, std::string(ABADDON_DEFAULT_RESOURCE_DIR)}) { + if (util::IsFolder(path + "/res") && util::IsFolder(path + "/css")) { + found_path = path; + found = true; + return found_path; + } + } } spdlog::get("discord")->warn("cant find a resources folder, will try to load from cwd");