Skip to content
Snippets Groups Projects
Commit a8d8b31d authored by Simon McVittie's avatar Simon McVittie
Browse files

Cope with games that don't follow the XDG basedir spec

parent 16c04715
Branches
Tags
No related merge requests found
...@@ -287,14 +287,6 @@ TODO ...@@ -287,14 +287,6 @@ TODO
They'll need some new special-case option analogous to They'll need some new special-case option analogous to
Flatpak's `--filesystem=xdg-music:ro`. Flatpak's `--filesystem=xdg-music:ro`.
* To avoid [weird behaviour][] when part of a game respects
`XDG_CONFIG_HOME` and part of it hard-codes `~/.config`, maybe we
should make `$fake_home/config` a synonym (bind-mount) for
`$fake_home/.config`, and the same for `$fake_home/.local/share` with
`$fake_home/data` and `$fake_home/.cache` with `$fake_home/cache`?
[weird behaviour]: https://www.ctrl.blog/entry/flatpak-steamcloud-xdg
Design Design
------ ------
...@@ -307,14 +299,22 @@ freedesktop.org app ID is based on its Steam AppID, for example ...@@ -307,14 +299,22 @@ freedesktop.org app ID is based on its Steam AppID, for example
`com.steampowered.App70` for Half-Life. `com.steampowered.App70` for Half-Life.
For the game, `XDG_CONFIG_HOME`, `XDG_DATA_HOME` and `XDG_CACHE_HOME` For the game, `XDG_CONFIG_HOME`, `XDG_DATA_HOME` and `XDG_CACHE_HOME`
are set to the `./config`, `./data` and `./cache` directories inside are set to the `./.config`, `./.local/share` and `./.cache` directories
its private home directory, so well-behaved freedesktop-style apps inside its private home directory, so that well-behaved freedesktop-style
will write there. apps will write there, and badly-behaved freedesktop-style apps that
ignore the environment variables and hard-code their default values will
*also* write there.
* Example: [X3: Terran Conflict][] writes to `$XDG_CONFIG_HOME/EgoSoft/X3TC` * Example: [X3: Terran Conflict][] writes to `$XDG_CONFIG_HOME/EgoSoft/X3TC`
* Example: Mesa writes to `$XDG_CACHE_HOME/mesa` (assuming * Example: Mesa writes to `$XDG_CACHE_HOME/mesa` (assuming
`$MESA_GLSL_CACHE_DIR` is unset) `$MESA_GLSL_CACHE_DIR` is unset)
`./config`, `./data` and `./cache` in the private home directory are symbolic
links to `.config`, `.local/share` and `.cache` respectively, for better
discoverability and compatibility with Flatpak (which uses those directories in
`~/.var/app` as its usual values for `XDG_CONFIG_HOME`, `XDG_DATA_HOME` and
`XDG_CACHE_HOME`).
Anything that hard-codes a path relative to `$HOME` (including `.config`, Anything that hard-codes a path relative to `$HOME` (including `.config`,
`.local/share` or `.cache`) will write to the corresponding directory in `.local/share` or `.cache`) will write to the corresponding directory in
`~/.var/app`. This is the same as the behaviour of a Flatpak app with `~/.var/app`. This is the same as the behaviour of a Flatpak app with
......
...@@ -642,14 +642,24 @@ else ...@@ -642,14 +642,24 @@ else
bwrap_options+=(--bind "$fake_home" "$fake_home") bwrap_options+=(--bind "$fake_home" "$fake_home")
# Set up /var/tmp, XDG_*_HOME like Flatpak does # Set up /var/tmp, XDG_*_HOME like Flatpak does
mkdir -m700 -p "$fake_home/cache" mkdir -m700 -p "$fake_home/.cache"
mkdir -m700 -p "$fake_home/cache/tmp" mkdir -m700 -p "$fake_home/.cache/tmp"
bwrap_options+=(--bind "$fake_home/cache/tmp" /var/tmp) if [ ! -e "$fake_home/cache" ]; then
bwrap_options+=(--setenv XDG_CACHE_HOME "$fake_home/cache") ln -fns .cache "$fake_home/cache"
mkdir -m700 -p "$fake_home/config" fi
bwrap_options+=(--setenv XDG_CONFIG_HOME "$fake_home/config") bwrap_options+=(--bind "$fake_home/.cache/tmp" /var/tmp)
mkdir -m700 -p "$fake_home/data" bwrap_options+=(--setenv XDG_CACHE_HOME "$fake_home/.cache")
bwrap_options+=(--setenv XDG_DATA_HOME "$fake_home/data") mkdir -m700 -p "$fake_home/.config"
if [ ! -e "$fake_home/config" ]; then
ln -fns .config "$fake_home/config"
fi
bwrap_options+=(--setenv XDG_CONFIG_HOME "$fake_home/.config")
mkdir -m700 -p "$fake_home/.local"
mkdir -m700 -p "$fake_home/.local/share"
if [ ! -e "$fake_home/data" ]; then
ln -fns .local/share "$fake_home/data"
fi
bwrap_options+=(--setenv XDG_DATA_HOME "$fake_home/.local/share")
} }
# These might be API entry points, according to .steam/steam/steam.sh. # These might be API entry points, according to .steam/steam/steam.sh.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment