diff --git a/README.md b/README.md index a06f2a535448925275a46f162b822cfa8b2c5e9e..7575ce8b5530286af5183260a2e3bdbfc0225ce5 100644 --- a/README.md +++ b/README.md @@ -287,14 +287,6 @@ TODO They'll need some new special-case option analogous to 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 ------ @@ -307,14 +299,22 @@ freedesktop.org app ID is based on its Steam AppID, for example `com.steampowered.App70` for Half-Life. For the game, `XDG_CONFIG_HOME`, `XDG_DATA_HOME` and `XDG_CACHE_HOME` -are set to the `./config`, `./data` and `./cache` directories inside -its private home directory, so well-behaved freedesktop-style apps -will write there. +are set to the `./.config`, `./.local/share` and `./.cache` directories +inside its private home directory, so that well-behaved freedesktop-style +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: Mesa writes to `$XDG_CACHE_HOME/mesa` (assuming `$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`, `.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 diff --git a/pressure-vessel-wrap b/pressure-vessel-wrap index 41e97b89290d58ecbd44fdf36262a80b5592ee4d..6d502beaf30d8cce6d29b4b9b4362390283aa32a 100755 --- a/pressure-vessel-wrap +++ b/pressure-vessel-wrap @@ -642,14 +642,24 @@ else bwrap_options+=(--bind "$fake_home" "$fake_home") # Set up /var/tmp, XDG_*_HOME like Flatpak does - mkdir -m700 -p "$fake_home/cache" - mkdir -m700 -p "$fake_home/cache/tmp" - bwrap_options+=(--bind "$fake_home/cache/tmp" /var/tmp) - bwrap_options+=(--setenv XDG_CACHE_HOME "$fake_home/cache") - mkdir -m700 -p "$fake_home/config" - bwrap_options+=(--setenv XDG_CONFIG_HOME "$fake_home/config") - mkdir -m700 -p "$fake_home/data" - bwrap_options+=(--setenv XDG_DATA_HOME "$fake_home/data") + mkdir -m700 -p "$fake_home/.cache" + mkdir -m700 -p "$fake_home/.cache/tmp" + if [ ! -e "$fake_home/cache" ]; then + ln -fns .cache "$fake_home/cache" + fi + bwrap_options+=(--bind "$fake_home/.cache/tmp" /var/tmp) + bwrap_options+=(--setenv XDG_CACHE_HOME "$fake_home/.cache") + 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.