mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
add --config flag to modify config path
+ use getters instead of constants in settings classes + refactor previous references + move get_xdg_config_dir() from settings.py to app.utils.xdg_utils.py
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
|
||||
|
||||
def get_xdg_config_dir():
|
||||
"""
|
||||
Returns the XDG_CONFIG_HOME environment variable if it exists, otherwise
|
||||
returns the default config directory. If none of those exist, returns the
|
||||
user's home directory.
|
||||
"""
|
||||
xdg_config_home = os.environ.get("XDG_CONFIG_HOME")
|
||||
|
||||
if xdg_config_home:
|
||||
return xdg_config_home
|
||||
|
||||
try:
|
||||
alt_dir = os.path.join(os.environ.get("HOME"), ".config")
|
||||
|
||||
if os.path.exists(alt_dir):
|
||||
return alt_dir
|
||||
except TypeError:
|
||||
return os.path.expanduser("~")
|
||||
Reference in New Issue
Block a user