Skip to content

Commit

Permalink
Presets: Add ability to specify preset_path via env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ForTheReallys authored and flightlessmango committed Nov 18, 2023
1 parent ea725ed commit b3fa8f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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).

Expand Down
5 changes: 3 additions & 2 deletions src/overlay_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit b3fa8f5

Please sign in to comment.