Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving #__get_dirs__ logic #11

Open
stdedos opened this issue Jul 28, 2024 · 0 comments
Open

Improving #__get_dirs__ logic #11

stdedos opened this issue Jul 28, 2024 · 0 comments

Comments

@stdedos
Copy link

stdedos commented Jul 28, 2024

mplug/src/mplug/mplug.py

Lines 286 to 312 in e18d8c4

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant