|
def __get_dirs__(self): |
|
"""Find the directory paths by using environment variables or |
|
hardcoded fallbacks.""" |
|
xdg_data = os.getenv("XDG_DATA_HOME") |
|
xdg_conf = os.getenv("XDG_CONFIG_HOME") |
|
appdata = os.getenv("APPDATA") |
|
mpv_home = os.getenv("MPV_HOME") |
|
# Directory for MPlug this is where all plugin files will be stored |
|
if xdg_data: |
|
self.workdir = Path(xdg_data) / "mplug" |
|
elif appdata: |
|
self.workdir = Path(appdata) / "mplug" |
|
else: |
|
self.workdir = Path.home() / ".mplug" |
|
# MPV directory usually ~/.config/mpv on Linux/Mac |
|
if mpv_home: |
|
self.mpvdir = Path(mpv_home) |
|
elif xdg_conf: |
|
self.mpvdir = Path(xdg_conf) / "mpv" |
|
elif appdata: |
|
self.mpvdir = Path(appdata) / "mpv" |
|
else: |
|
self.mpvdir = Path.home() / ".mpv" |
|
logging.info( |
|
"No environment variable found, guessing %s as mpv config folder.", |
|
self.mpvdir, |
|
) |
According to https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#:~:text=and%20ignore%0A%20%20%20%20%20%20it.-,environment%20variables,-%24XDG_DATA_HOME%20defines%20the:
$XDG_DATA_HOME defines the base directory relative to which user-specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
$XDG_CONFIG_HOME defines the base directory relative to which user-specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
I believe the script should be amended, also the way the checks work: If one of the directories exist, then searching should stop there.
It'd be nice to verify if the script is configured according to mpv's rules (https://mpv.io/manual/master/#files)
mplug/src/mplug/mplug.py
Lines 286 to 312 in e18d8c4
According to https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#:~:text=and%20ignore%0A%20%20%20%20%20%20it.-,environment%20variables,-%24XDG_DATA_HOME%20defines%20the:
I believe the script should be amended, also the way the checks work: If one of the directories exist, then searching should stop there.
It'd be nice to verify if the script is configured according to mpv's rules (https://mpv.io/manual/master/#files)