Presets: Add ability to specify preset_path via env variables

pull/1181/head
Alex Maese 6 months ago committed by flightlessmango
parent ea725ed1d2
commit b3fa8f5c29

@ -21,7 +21,7 @@ A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and m
- [Normal usage](#normal-usage)
- [OpenGL](#opengl)
- [Hud configuration](#hud-configuration)
- [Environment Variables: **`MANGOHUD_CONFIG`** and **`MANGOHUD_CONFIGFILE`**](#environment-variables-mangohud_config-and-mangohud_configfile)
- [Environment Variables: **`MANGOHUD_CONFIG`**, **`MANGOHUD_CONFIGFILE`**, and **`MANGOHUD_PRESETSFILE`**](#environment-variables)
- [Vsync](#vsync)
- [OpenGL Vsync](#opengl-vsync)
- [Vulkan Vsync](#vulkan-vsync)
@ -289,12 +289,14 @@ You can find an example config in /usr/share/doc/mangohud
---
### Environment Variables: **`MANGOHUD_CONFIG`** and **`MANGOHUD_CONFIGFILE`**
### Environment Variables
You can also customize the hud by using the `MANGOHUD_CONFIG` environment variable while separating different options with a comma. This takes priority over any config file.
You can also specify configuration file with `MANGOHUD_CONFIGFILE=/path/to/config` for applications whose names are hard to guess (java, python etc).
You can also specify presets file with `MANGOHUD_PRESETSFILE=/path/to/config`. This is especially useful when running mangohud in a sandbox such as flatpak.
A partial list of parameters are below. See the config file for a complete list.
Parameters that are enabled by default have to be explicitly disabled. These (currently) are `fps`, `frame_timing`, `cpu_stats` (cpu load), `gpu_stats` (gpu load), and each can be disabled by setting the corresponding variable to 0 (e.g., fps=0).

@ -983,9 +983,9 @@ parse_overlay_config(struct overlay_params *params,
}
bool parse_preset_config(int preset, struct overlay_params *params){
const std::string data_dir = get_data_dir();
const char *presets_file_env = getenv("MANGOHUD_PRESETSFILE");
const std::string config_dir = get_config_dir();
std::string preset_path = config_dir + "/MangoHud/" + "presets.conf";
std::string preset_path = presets_file_env ? presets_file_env : config_dir + "/MangoHud/" + "presets.conf";
char preset_string[20];
snprintf(preset_string, sizeof(preset_string), "[preset %d]", preset);
@ -994,6 +994,7 @@ bool parse_preset_config(int preset, struct overlay_params *params){
stream.imbue(std::locale::classic());
if (!stream.good()) {
SPDLOG_ERROR("Failed to read presets file: '{}'", preset_path);
return false;
}

Loading…
Cancel
Save