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

Set default data directory according to XDG directory specs and add archlinux installation instructions #22

Merged
merged 4 commits into from
Mar 18, 2023

Conversation

otuva
Copy link
Contributor

@otuva otuva commented Mar 18, 2023

The script in this current version will try to put data under ~/spn-data by default
With this change, however, it will try to read XDG_DATA_HOME variable and if it cannot find the variable will default to $HOME/.local/share/

The script in this current version will try to put data under ~/spn-data
With this change it will try to read XDG_DATA_HOME variable and if it cannot find the variable will default to $HOME/.local/share/
@overcast07
Copy link
Owner

overcast07 commented Mar 18, 2023

I primarily run this script on macOS, which doesn't support the XDG_DATA_HOME variable. I would prefer for the current default of $HOME/spn-data to be retained, in order to make the folder easier to find, rather than putting it in a hidden folder.

This change would make the script unusable by default on macOS, since the parent folder needs to exist before mkdir can create the new folder. Currently, I get the error mkdir: /Users/user\/.local\/share: No such file or directory. The backslashes appear to be unnecessary, but I don't know if this is OS-specific behavior. I'm also not sure if the $HOME/local/share folder exists on every Unix system or if it needs to be created in some cases.

@otuva
Copy link
Contributor Author

otuva commented Mar 18, 2023

This should fix it, I didn't think about macOS on the first commit :)

in order to make the folder easier to find, rather than putting it in a hidden folder.

I don't think findability matters that much here, it's about not polluting the user space, which follows Apple's guidelines

And under macOS it still is pretty findable, I think. Just 2 directories

Current directory location is not just aesthetics either, it will cause problems to anyone using industry-standard backup practices

https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFileSystem/Articles/WhereToPutFiles.html

The backslashes appear to be unnecessary

The default value used in case variable doesn't exist read raw and any special characters need to be escaped. Because it's a path anyway, probably wouldn't matter too much. If you want, you can delete it but here's what it looks like

parent="${XDG_DATA_HOME:-$HOME\/.local\/share}/spn-data"
echo $parent 
/home/tfp/.local/share/spn-data

on every Unix system or if it needs to be created in some cases

If it's a modern system (after 2000s) 99.9999% it will exist.

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

@otuva
Copy link
Contributor Author

otuva commented Mar 18, 2023

Anyway, as per your request I've made those modifications too, looking forward for your feedback :)

@overcast07
Copy link
Owner

Bash on macOS doesn't seem to ignore the backslashes. The below behavior occurs for me.

parent="${XDG_DATA_HOME:-$HOME\/.local\/share}/spn-data"; echo $parent
/Users/user\/.local\/share/spn-data
parent="${XDG_DATA_HOME:-$HOME/.local/share}/spn-data"; echo $parent 
/Users/user/.local/share/spn-data

@overcast07
Copy link
Owner

I'll merge the pull request once I'm done reviewing the code and testing on my own computer.

@overcast07 overcast07 merged commit 209475e into overcast07:main Mar 18, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants