add ABADDON_CONFIG environment variable

This commit is contained in:
ouwou 2021-06-30 21:45:26 -04:00
parent f7ac0f2a1e
commit 4b089606ea
3 changed files with 21 additions and 2 deletions

View File

@ -54,7 +54,11 @@ Or, do steps 1 and 2, and open CMakeLists.txt in Visual Studio if `vcpkg integra
- MacOS: [here](https://nightly.link/uowuo/abaddon/workflows/ci/master/build-macos-RelWithDebInfo.zip) unsigned, unpackaged, requires gtkmm3 (e.g. from homebrew)
- Linux: [here](https://nightly.link/uowuo/abaddon/workflows/ci/master/build-linux-MinSizeRel.zip) unpackaged (for now), requires gtkmm3. built on Ubuntu 18.04 + gcc9
⚠️ Make sure you start from the directory where `css` and `res` are or else stuff will be broken
⚠️ If you use Windows, make sure to start from the directory containing `css` and `res`
If you don't use Windows, `css` and `res` can be loaded from `/usr/share/abaddon`
`abaddon.ini` will also be automatically used if located at `~/.config/abaddon/abaddon.ini` and there is no `abaddon.ini` in the working directory
#### Dependencies:
* [gtkmm](https://www.gtkmm.org/en/)
@ -196,3 +200,8 @@ For example, memory_db would be set by adding `memory_db = true` under the line
#### misc
* linkcolor (string) - color to use for links in messages
### Environment variables
* ABADDON_NO_FC (Windows only) - don't use custom font config
* ABADDON_CONFIG - change path of configuration file to use. relative to cwd or can be absolute

View File

@ -22,7 +22,7 @@
Abaddon::Abaddon()
: m_settings(Platform::FindConfigFile())
, m_emojis(GetResPath() + "/emojis.bin")
, m_emojis(GetResPath("/emojis.bin"))
, m_discord(m_settings.GetUseMemoryDB()) { // stupid but easy
LoadFromSettings();

View File

@ -83,6 +83,9 @@ std::string Platform::FindResourceFolder() {
}
std::string Platform::FindConfigFile() {
const auto x = std::getenv("ABADDON_CONFIG");
if (x != nullptr)
return x;
return "./abaddon.ini";
}
@ -103,6 +106,10 @@ std::string Platform::FindResourceFolder() {
}
std::string Platform::FindConfigFile() {
const auto x = std::getenv("ABADDON_CONFIG");
if (x != nullptr)
return x;
const auto home_path = std::string(std::getenv("HOME")) + "/.config/abaddon/abaddon.ini";
for (const auto path : { "./abaddon.ini"s, home_path }) {
if (IsFile(path)) return path;
@ -117,6 +124,9 @@ std::string Platform::FindResourceFolder() {
}
std::string Platform::FindConfigFile() {
const auto x = std::getenv("ABADDON_CONFIG");
if (x != nullptr)
return x;
puts("unknown OS, trying to load config from cwd");
return "./abaddon.ini";
}