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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions common/desktop-exports
Original file line number Diff line number Diff line change
Expand Up @@ -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.


# Run xdg-user-dirs-update
if [ `which xdg-user-dirs-update` ]; then
xdg-user-dirs-update
fi

# Create $XDG_RUNTIME_DIR if not exists (to be removed when LP: #1656340 is fixed)
[ -n "$XDG_RUNTIME_DIR" ] && mkdir -p $XDG_RUNTIME_DIR -m 700

Expand Down
5 changes: 5 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ parts:
- unity-gtk3-module
- libappindicator3-1
- locales-all
- xdg-user-dirs
qt4:
source: .
source-subdir: qt
Expand Down Expand Up @@ -171,6 +172,7 @@ parts:
- unity-gtk2-module
- locales-all
- libappindicator1
- xdg-user-dirs
desktop-gtk3:
source: .
source-subdir: gtk
Expand All @@ -193,6 +195,7 @@ parts:
- unity-gtk3-module
- libappindicator3-1
- locales-all
- xdg-user-dirs
desktop-qt4:
source: .
source-subdir: qt
Expand All @@ -215,6 +218,7 @@ parts:
- appmenu-qt
- locales-all
- sni-qt
- xdg-user-dirs
desktop-qt5:
source: .
source-subdir: qt
Expand All @@ -236,6 +240,7 @@ parts:
- libqt5svg5 # for loading icon themes which are svg
- appmenu-qt5
- locales-all
- xdg-user-dirs
desktop-glib-only:
source: .
source-subdir: glib-only
Expand Down