From 0863b25d82104c9d598a1e598a348d7e72344d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C5=9Eafak?= Date: Sat, 3 May 2025 18:31:45 +0300 Subject: [PATCH] Better approach for detemining the correct configuration folder for Linux and MacOS, using platformdirs --- CHANGELOG.md | 7 +------ abogen/utils.py | 7 +++---- abogen/voice_profiles.py | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28eb291..d3d73b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1 @@ -- Merge pull request [#7](https://github.com/denizsafak/abogen/pull/7) by [@jborza](https://github.com/jborza) that improves voice preview and documentation. -- Fixed the issue when a voice is selected, the voice mixer tries to pre-select that voice and ignores existing profiles. -- Fixed the error while renaming the default "New profile" in the voice mixer. -- Fixed subtitle_combo enabling/disabling when a voice in the voice mixer is selected. -- Prevented using special characters in the profile name to avoid conflicts. -- Improved invalid profile handling in the voice mixer. \ No newline at end of file +- Better approach for detemining the correct configuration folder for Linux and MacOS, using platformdirs. \ No newline at end of file diff --git a/abogen/utils.py b/abogen/utils.py index f65bc8e..d8cd5cd 100644 --- a/abogen/utils.py +++ b/abogen/utils.py @@ -66,10 +66,9 @@ def get_version(): # Define config path def get_user_config_path(): - if os.name == "nt": - config_dir = os.path.join(os.environ["APPDATA"], "abogen") - else: - config_dir = os.path.join(os.path.expanduser("~"), ".config", "abogen") + from platformdirs import user_config_dir + # Use platformdirs to get the user configuration directory + config_dir = user_config_dir("abogen", appauthor=False, roaming=True) os.makedirs(config_dir, exist_ok=True) return os.path.join(config_dir, "config.json") diff --git a/abogen/voice_profiles.py b/abogen/voice_profiles.py index a77a98a..637ecce 100644 --- a/abogen/voice_profiles.py +++ b/abogen/voice_profiles.py @@ -1,6 +1,6 @@ import os import json -from utils import get_user_config_path, get_resource_path +from utils import get_user_config_path def _get_profiles_path():