Skip to content
openmw-config
reference

Paths and environment

Where configs and data live on each platform, what each token means, Flatpak, and every environment variable the crate reads.

OpenMW’s paths have similar names and different meanings. The crate keeps them apart, and so should you: the user config directory, the global config directory and the global data directory are three different places.

Per platform#

LinuxLinux, FlatpakmacOSWindows
User config, ?userconfig?$XDG_CONFIG_HOME/openmw, or ~/.config/openmw~/.var/app/<app-id>/config/openmw~/Library/Preferences/openmwDocuments\My Games\openmw
User data, ?userdata?$XDG_DATA_HOME/openmw, or ~/.local/share/openmw~/.var/app/<app-id>/data/openmw~/Library/Application Support/openmwDocuments\My Games\openmw
Default data-local?userdata?/data?userdata?/data?userdata?/data?userdata?/data
?local?The running program’s directoryThe running program’s directoryContents/Resources in an app bundle, otherwise the program’s directoryThe running program’s directory
?global?/usr/share/games/app/share/games/Library/Application SupportNone
Global config directory/etc/openmw/app/etc/openmwNoneNone
  • ~ is HOME. On Windows it is USERPROFILE, then HOMEDRIVE and HOMEPATH together, then HOME.
  • Windows’ Documents folder comes from the Known Folder API, so a Documents folder moved elsewhere, or into OneDrive, is found where it is.
  • On Android the user config is /storage/emulated/0/Alpha3/config and the user data /storage/emulated/0/Alpha3.
  • With no global config directory, root discovery looks only beside the executable. With no ?global?, the token stays unresolved where it is written.

Flatpak#

Flatpak mode exists on Linux only. It is on when any of these holds:

  • OPENMW_CONFIG_USING_FLATPAK is set, to anything;
  • FLATPAK_ID is set, which Flatpak does for every app it runs;
  • /.flatpak-info exists.

The app id is OPENMW_FLATPAK_ID, then FLATPAK_ID, then org.openmw.OpenMW, skipping blank values. A tool running in its own Flatpak and reading OpenMW’s config should set OPENMW_FLATPAK_ID=org.openmw.OpenMW, or it will look in its own sandbox’s directories.

Environment variables#

VariableEffect
OPENMW_CONFIGThe root openmw.cfg for from_env(). The only candidate when set.
OPENMW_CONFIG_DIRDirectories to search for the root openmw.cfg, separated by ; on Windows and : elsewhere.
OPENMW_GLOBAL_CONFIG_PATHReplaces the global config directory. A crate setting for packagers and tests, not an OpenMW one.
OPENMW_GLOBAL_PATHReplaces ?global?.
OPENMW_CONFIG_USING_FLATPAKTurns Flatpak mode on.
OPENMW_FLATPAK_ID, FLATPAK_IDThe Flatpak app id. FLATPAK_ID also turns Flatpak mode on.
XDG_CONFIG_HOME, XDG_DATA_HOMELinux user config and data roots. Empty values are ignored.
HOME, USERPROFILE, HOMEDRIVE, HOMEPATHThe home directory.
PWDWhen a relative path is made absolute and PWD names the current directory, it is used as written, so paths through symlinked directories keep their spelling.
CFG_DEBUGSet to anything: print what loading does to standard output.

Functions#

Each location has a pair of functions. try_default_* returns a Result and fails with ConfigError::PlatformPathUnavailable where the platform has no such place. default_* returns the path and panics instead: use it only where the location must exist.

ResolvesFalliblePanicking
User config directory, ?userconfig?try_default_config_path()default_config_path()
User openmw.cfgtry_default_user_config_file()default_user_config_file()
User data, ?userdata?try_default_userdata_path()default_userdata_path()
Default data-localdefault_data_local_path()
?local?try_default_local_path()default_local_path()
?global?try_default_global_path()default_global_path()
Global config directorytry_default_global_config_path()default_global_config_path()
Root openmw.cfg, beside the executable or globaltry_default_root_config_path()default_root_config_path()
Root openmw.cfg, else the user’stry_default_root_or_user_config_path()default_root_or_user_config_path()

The root functions run steps 3 and 4 of root discovery and ignore OPENMW_CONFIG and OPENMW_CONFIG_DIR, which only from_env() reads. The path reference has each function’s errors.