diff --git a/python/openshell/release_formula_test.py b/python/openshell/release_formula_test.py index b3ab871ae..9e6d5ee40 100644 --- a/python/openshell/release_formula_test.py +++ b/python/openshell/release_formula_test.py @@ -113,6 +113,15 @@ def test_snap_wrapper_uses_optional_gateway_config_without_generating_toml() -> assert 'exec "${SNAP}/bin/openshell-gateway" "$@"' in wrapper +def test_snap_cli_uses_snap_owned_xdg_dirs() -> None: + repo_root = Path(__file__).resolve().parents[2] + snapcraft = (repo_root / "snapcraft.yaml").read_text(encoding="utf-8") + + assert snapcraft.count('XDG_CONFIG_HOME: "$SNAP_USER_COMMON/.config"') == 2 + assert snapcraft.count('XDG_DATA_HOME: "$SNAP_USER_COMMON/.local/share"') == 2 + assert snapcraft.count('XDG_STATE_HOME: "$SNAP_USER_COMMON/.local/state"') == 2 + + def test_rpm_spec_uses_gateway_defaults_without_config_helper() -> None: repo_root = Path(__file__).resolve().parents[2] spec = (repo_root / "openshell.spec").read_text(encoding="utf-8") diff --git a/snapcraft.yaml b/snapcraft.yaml index 01d90366e..f7354aa01 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -62,6 +62,10 @@ platforms: apps: openshell: command: bin/openshell + environment: + XDG_CONFIG_HOME: "$SNAP_USER_COMMON/.config" + XDG_DATA_HOME: "$SNAP_USER_COMMON/.local/share" + XDG_STATE_HOME: "$SNAP_USER_COMMON/.local/state" plugs: - home - network @@ -70,6 +74,10 @@ apps: term: command: bin/openshell term desktop: meta/gui/term.desktop + environment: + XDG_CONFIG_HOME: "$SNAP_USER_COMMON/.config" + XDG_DATA_HOME: "$SNAP_USER_COMMON/.local/share" + XDG_STATE_HOME: "$SNAP_USER_COMMON/.local/state" plugs: - home - network