From 38f6eaa31ad7db130057c508e1205faa36535794 Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Fri, 14 Nov 2025 21:04:10 +0100 Subject: [PATCH] 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]: https://github.com/juce-framework/JUCE/issues/1184 --- Changelog.md | 4 ++++ Source/Main.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/Changelog.md b/Changelog.md index fc35fb6d..a80e1303 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +* **Breaking Change**: Respect `XDG_CONFIG_HOME` on Linux. + ## [1.2.0] - 2025-04-15 ### Added diff --git a/Source/Main.cpp b/Source/Main.cpp index 17f4222a..465aa075 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -31,6 +31,16 @@ class MStarPlayerApplication : public juce::JUCEApplication juce::PropertiesFile::Options options; options.applicationName = "MStarPlayer"; options.filenameSuffix = ".settings"; +#ifdef JUCE_LINUX + if (const char* path = std::getenv("XDG_CONFIG_HOME")) + { + options.folderName = path + juce::String("/MStarPlayer"); + } + else if (const char* home = std::getenv("HOME")) + { + options.folderName = home + juce::String("/.config/MStarPlayer"); + } +#endif m_applicationProperties.setStorageParameters(options); if (m_applicationProperties.getUserSettings()->getValue("language") == "de")