Skip to content

Commit 8852f50

Browse files
committed
Respect XDG_CONFIG_HOME on Linux
The application's configuration is stored using `ApplicationProperties` which doesn't consider the *XDG Base Directory Specification*. There is `File::userApplicationDataDirectory` but it also doesn't respect it according to an upstream [bug report]. Supporting the full specification is more effort but just supporting `XDG_CONFIG_HOME` already addresses the common issue of the home directory being spammed with configuration files. So just read that environment variable or use its default to set the `folderName`, with an appended application name since the specification suggests to also use a subfolder. This is a breaking change for Linux users but since none are known at the time it seems acceptable to just switch instead of supporting some form of migration. It's also mentioned in the change log. [bug report]: juce-framework/JUCE#1184
1 parent 3fa5383 commit 8852f50

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
* *Breaking Change*: Respect `XDG_CONFIG_HOME` on Linux.
13+
1014
## [1.2.0] - 2025-04-15
1115

1216
### Added

Source/Main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ class MStarPlayerApplication : public juce::JUCEApplication
3131
juce::PropertiesFile::Options options;
3232
options.applicationName = "MStarPlayer";
3333
options.filenameSuffix = ".settings";
34+
#ifdef JUCE_LINUX
35+
if (const char* path = std::getenv("XDG_CONFIG_HOME"))
36+
{
37+
options.folderName = path + juce::String("/MStarPlayer");
38+
}
39+
else if (const char* home = std::getenv("HOME"))
40+
{
41+
options.folderName = home + juce::String("/.config/MStarPlayer");
42+
}
43+
#endif
3444
m_applicationProperties.setStorageParameters(options);
3545

3646
if (m_applicationProperties.getUserSettings()->getValue("language") == "de")

0 commit comments

Comments
 (0)