change: parse real home in sandbox
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run

This commit is contained in:
aclist committed 2026-11-19 07:50:29 +09:00
1 parent 16578eaeb3
commit b42be20dc3
5 files changed
+24 -12

No files matched your search

+5 -4
View File
@@ -12,9 +12,7 @@ from typing import Any, Generator, Union
from warnings import deprecated from warnings import deprecated
from dzgui.api.acf import ACF from dzgui.api.acf import ACF
from dzgui.const.endpoints import VALIDATE from dzgui.config.xdg import get_real_home
from dzgui.init.prereqs import has_any_client
from dzgui.init.prereqs import has_flatpak_client, has_steam_client
from dzgui.const.constants import ( from dzgui.const.constants import (
APPID_DAYZ, APPID_DAYZ,
APPID_DAYZ_EXP, APPID_DAYZ_EXP,
@@ -36,7 +34,10 @@ from dzgui.const.endpoints import (
STEAM_PUBLISHED_FILES, STEAM_PUBLISHED_FILES,
STEAM_SUB, STEAM_SUB,
STEAM_UNSUB, STEAM_UNSUB,
VALIDATE,
) )
from dzgui.init.prereqs import has_any_client
from dzgui.init.prereqs import has_flatpak_client, has_steam_client
from dzgui.strings import wizard from dzgui.strings import wizard
from dzgui.strings.errors import api_validation_error, workshop_endpoint_error from dzgui.strings.errors import api_validation_error, workshop_endpoint_error
from dzgui.util.bash import concat_bash_args from dzgui.util.bash import concat_bash_args
@@ -65,7 +66,7 @@ class VDFLoadError(Exception):
def get_steam_paths() -> list[tuple[Path, str]]: def get_steam_paths() -> list[tuple[Path, str]]:
paths = [] paths = []
if has_any_client(): if has_any_client():
HOME = Path.home() HOME = get_real_home()
env = os.environ.get("XDG_DATA_HOME") env = os.environ.get("XDG_DATA_HOME")
if env is not None: if env is not None:
XDG_DATA_HOME = Path(env) XDG_DATA_HOME = Path(env)
+3 -1
View File
@@ -3,6 +3,7 @@ import textwrap
from pathlib import Path from pathlib import Path
from dzgui.config.xdg import get_real_home
from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents
@@ -36,7 +37,8 @@ def write_desktop_file(exe_path: Path) -> Path:
def write_desktop_shortcut(desktop_file: Path) -> None: def write_desktop_shortcut(desktop_file: Path) -> None:
# NOTE: necessarily depends on the above (UI blocks creation without XDG entry first) # NOTE: necessarily depends on the above (UI blocks creation without XDG entry first)
link = Path.home().joinpath("Desktop/dzgui.desktop") home = get_real_home()
link = home.joinpath("Desktop/dzgui.desktop")
make_parents(link) make_parents(link)
if link.exists(): if link.exists():
link.unlink() link.unlink()
+6 -2
View File
@@ -48,13 +48,17 @@ def is_writeable(path_str: str) -> bool:
file.unlink() file.unlink()
return True return True
def get_real_home() -> Path:
def get_xdg_paths() -> dict[str, Path]:
home = Path.home() home = Path.home()
if resolved := os.environ.get("SNAP_REAL_HOME"): # Snap if resolved := os.environ.get("SNAP_REAL_HOME"): # Snap
home = Path(resolved) home = Path(resolved)
elif resolved := os.environ.get("HOME"): # Flatpak elif resolved := os.environ.get("HOME"): # Flatpak
home = Path(resolved) home = Path(resolved)
return home
def get_xdg_paths() -> dict[str, Path]:
home = get_real_home()
xdg_paths = { xdg_paths = {
"XDG_CONFIG_HOME": home / ".config", "XDG_CONFIG_HOME": home / ".config",
"XDG_STATE_HOME": home / ".local" / "state", "XDG_STATE_HOME": home / ".local" / "state",
+7 -4
View File
@@ -12,13 +12,15 @@ from dzgui.const.constants import (
LEGACY_IPS_PATH, LEGACY_IPS_PATH,
) )
from dzgui.config.convert import rc2json from dzgui.config.convert import rc2json
from dzgui.config.xdg import get_real_home
from dzgui.util._json import read_json, write_json from dzgui.util._json import read_json, write_json
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
def migrate_legacy_conf(config: Path) -> Any: def migrate_legacy_conf(config: Path) -> Any:
old_conf = Path.home() / LEGACY_CONFIG_PATH home = get_real_home()
old_conf = home / LEGACY_CONFIG_PATH
j = rc2json(old_conf) j = rc2json(old_conf)
return json.loads(j) return json.loads(j)
@@ -44,7 +46,8 @@ def convert_cols_file(res: Path) -> Any | None:
def migrate_cols_file(res: Path) -> None: def migrate_cols_file(res: Path) -> None:
# NOTE: filename "dzg.columns.json" is API 7 spec # NOTE: filename "dzg.columns.json" is API 7 spec
old_res = Path.home() / LEGACY_COLS_PATH home = get_real_home()
old_res = home / LEGACY_COLS_PATH
if old_res.is_file(): if old_res.is_file():
j = convert_cols_file(old_res) j = convert_cols_file(old_res)
if j is not None: if j is not None:
@@ -52,7 +55,7 @@ def migrate_cols_file(res: Path) -> None:
def copy_state_files(state_path: Path) -> None: def copy_state_files(state_path: Path) -> None:
home = Path.home() home = get_real_home()
legacy = home / ".local/state/dzgui" legacy = home / ".local/state/dzgui"
to_copy = [ to_copy = [
"dzg.res.json", "dzg.res.json",
@@ -71,7 +74,7 @@ def copy_state_files(state_path: Path) -> None:
def copy_ipdb(ips_path: Path) -> None: def copy_ipdb(ips_path: Path) -> None:
home = Path.home() home = get_real_home()
legacy = home / LEGACY_IPS_PATH legacy = home / LEGACY_IPS_PATH
if ips_path == legacy: if ips_path == legacy:
return return
+3 -1
View File
@@ -16,6 +16,7 @@ from dzgui.const.constants import (
LEGACY_CONFIG_PATH, LEGACY_CONFIG_PATH,
TMP_PATH, TMP_PATH,
) )
from dzgui.config.xdg import get_real_home
from dzgui.const.boilerplate import config_boilerplate from dzgui.const.boilerplate import config_boilerplate
from dzgui.const.endpoints import STEAM_API_SETUP from dzgui.const.endpoints import STEAM_API_SETUP
from dzgui.config import freedesktop from dzgui.config import freedesktop
@@ -506,7 +507,8 @@ class Assistant(Gtk.Assistant):
self.pages: dict[EnumeratedWizardPage, int] = {} self.pages: dict[EnumeratedWizardPage, int] = {}
legacy_path = Path.home().joinpath(LEGACY_CONFIG_PATH) home = get_real_home()
legacy_path = home.joinpath(LEGACY_CONFIG_PATH)
self.has_legacy_config = legacy_path.is_file() self.has_legacy_config = legacy_path.is_file()
for page in ( for page in (
self.page_intro, self.page_intro,