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

Ensure XDG_CONFIG_HOME is set and run xdg-user-dirs-update #74

Merged
merged 2 commits into from
Oct 2, 2017

Conversation

kenvandine
Copy link
Member

This fixes an issue with apps that use APIs such as get_user_special_dir to get XDG_XXX_DIR locations. This would be probably be better if we set XDG_XXX_DIR to directories of the host's homedir instead of in $SNAP_USER_DATA, however I don't see a way to get that dir. I think this PR is a step in the right direction.

@@ -62,6 +62,15 @@ mkdir -p $XDG_DATA_HOME
export XDG_CACHE_HOME=$SNAP_USER_DATA/.cache
mkdir -p $XDG_CACHE_HOME

# Set config folder to local path
export XDG_CONFIG_HOME=$SNAP_USER_DATA/.config
mkdir -p $XDG_CONFIG_HOME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that xdg user dirs are ~/Documents, ~/Videos and the like, and .config is an xdg base dir.

For .config, you definitely want to use $SNAP_USER_DATA like you are here, because /home/<user>/.config isn't accessible by the snap. Note that $HOME is set to $SNAP_USER_DATA when this code is run.

If, in the future, you wanted the home as configured via /etc/passwd, you can use:

getent passwd `id -u` | cut -d ':' -f 6

This is conceivably useful for xdg user dirs, like ~/Documents, for example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdstrand excellent tip for getting the home dir. Yeah, we definately want XDG_CONFIG_HOME to be in $SNAP_USER_DATA.

I'm contemplating using xdg-user-dirs-update to generate the user-dirs.dirs with the path to the user's homedir instead of $HOME. However, longer term that doesn't help us do away with the need for the "home" interface.

@lucyllewy
Copy link
Contributor

It looks like you've omitted the qt and gtk2 helpers from this fix (xdg-user-dirs is only added to stage-packages for gtk3 variants). Was that intentional? I would expect both gtk2 and qt variants to also respect the XDG paths, but that is a guess on my part. If they really don't respect the variables then it is fine as-is, but if they do follow those paths then we should add support to their launchers, too.

@kenvandine
Copy link
Member Author

@diddledan good catch, I added those as well.

@kenvandine kenvandine merged commit 1166119 into ubuntu:master Oct 2, 2017
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.

3 participants