mirror of
https://github.com/aclist/dztui.git
synced 2026-11-19 00:02:04 +01:00
This commit is contained in:
1 parent
16578eaeb3
commit
b42be20dc3
5 files changed
+24
-12
No files matched your search
+5
-4
@@ -12,9 +12,7 @@ from typing import Any, Generator, Union
|
||||
from warnings import deprecated
|
||||
|
||||
from dzgui.api.acf import ACF
|
||||
from dzgui.const.endpoints import VALIDATE
|
||||
from dzgui.init.prereqs import has_any_client
|
||||
from dzgui.init.prereqs import has_flatpak_client, has_steam_client
|
||||
from dzgui.config.xdg import get_real_home
|
||||
from dzgui.const.constants import (
|
||||
APPID_DAYZ,
|
||||
APPID_DAYZ_EXP,
|
||||
@@ -36,7 +34,10 @@ from dzgui.const.endpoints import (
|
||||
STEAM_PUBLISHED_FILES,
|
||||
STEAM_SUB,
|
||||
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.errors import api_validation_error, workshop_endpoint_error
|
||||
from dzgui.util.bash import concat_bash_args
|
||||
@@ -65,7 +66,7 @@ class VDFLoadError(Exception):
|
||||
def get_steam_paths() -> list[tuple[Path, str]]:
|
||||
paths = []
|
||||
if has_any_client():
|
||||
HOME = Path.home()
|
||||
HOME = get_real_home()
|
||||
env = os.environ.get("XDG_DATA_HOME")
|
||||
if env is not None:
|
||||
XDG_DATA_HOME = Path(env)
|
||||
|
||||
@@ -3,6 +3,7 @@ import textwrap
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -36,7 +37,8 @@ def write_desktop_file(exe_path: Path) -> Path:
|
||||
|
||||
def write_desktop_shortcut(desktop_file: Path) -> None:
|
||||
# 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)
|
||||
if link.exists():
|
||||
link.unlink()
|
||||
|
||||
+6
-2
@@ -48,13 +48,17 @@ def is_writeable(path_str: str) -> bool:
|
||||
file.unlink()
|
||||
return True
|
||||
|
||||
|
||||
def get_xdg_paths() -> dict[str, Path]:
|
||||
def get_real_home() -> Path:
|
||||
home = Path.home()
|
||||
if resolved := os.environ.get("SNAP_REAL_HOME"): # Snap
|
||||
home = Path(resolved)
|
||||
elif resolved := os.environ.get("HOME"): # Flatpak
|
||||
home = Path(resolved)
|
||||
return home
|
||||
|
||||
|
||||
def get_xdg_paths() -> dict[str, Path]:
|
||||
home = get_real_home()
|
||||
xdg_paths = {
|
||||
"XDG_CONFIG_HOME": home / ".config",
|
||||
"XDG_STATE_HOME": home / ".local" / "state",
|
||||
|
||||
@@ -12,13 +12,15 @@ from dzgui.const.constants import (
|
||||
LEGACY_IPS_PATH,
|
||||
)
|
||||
from dzgui.config.convert import rc2json
|
||||
from dzgui.config.xdg import get_real_home
|
||||
from dzgui.util._json import read_json, write_json
|
||||
|
||||
logger = logging.getLogger(APP_NAME)
|
||||
|
||||
|
||||
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)
|
||||
return json.loads(j)
|
||||
|
||||
@@ -44,7 +46,8 @@ def convert_cols_file(res: Path) -> Any | None:
|
||||
|
||||
def migrate_cols_file(res: Path) -> None:
|
||||
# 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():
|
||||
j = convert_cols_file(old_res)
|
||||
if j is not None:
|
||||
@@ -52,7 +55,7 @@ def migrate_cols_file(res: Path) -> None:
|
||||
|
||||
|
||||
def copy_state_files(state_path: Path) -> None:
|
||||
home = Path.home()
|
||||
home = get_real_home()
|
||||
legacy = home / ".local/state/dzgui"
|
||||
to_copy = [
|
||||
"dzg.res.json",
|
||||
@@ -71,7 +74,7 @@ def copy_state_files(state_path: Path) -> None:
|
||||
|
||||
|
||||
def copy_ipdb(ips_path: Path) -> None:
|
||||
home = Path.home()
|
||||
home = get_real_home()
|
||||
legacy = home / LEGACY_IPS_PATH
|
||||
if ips_path == legacy:
|
||||
return
|
||||
|
||||
@@ -16,6 +16,7 @@ from dzgui.const.constants import (
|
||||
LEGACY_CONFIG_PATH,
|
||||
TMP_PATH,
|
||||
)
|
||||
from dzgui.config.xdg import get_real_home
|
||||
from dzgui.const.boilerplate import config_boilerplate
|
||||
from dzgui.const.endpoints import STEAM_API_SETUP
|
||||
from dzgui.config import freedesktop
|
||||
@@ -506,7 +507,8 @@ class Assistant(Gtk.Assistant):
|
||||
|
||||
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()
|
||||
for page in (
|
||||
self.page_intro,
|
||||
|
||||
Reference in new issue
Block a user