Use HOST_ prefixed env vars for host XDG base dirs

This commit is contained in:
kramo
2023-12-17 11:46:54 +01:00
parent 7d0b9854d3
commit 5ab3085083
8 changed files with 20 additions and 13 deletions

View File

@@ -98,7 +98,7 @@ class BottlesSource(URLExecutableSource):
candidates=( candidates=(
shared.flatpak_dir / "com.usebottles.bottles" / "data" / "bottles", shared.flatpak_dir / "com.usebottles.bottles" / "data" / "bottles",
shared.data_dir / "bottles/", shared.data_dir / "bottles/",
shared.home / ".local" / "share" / "bottles", shared.host_data_dir / "bottles",
), ),
paths={ paths={
"library.yml": LocationSubPath("library.yml"), "library.yml": LocationSubPath("library.yml"),

View File

@@ -39,7 +39,7 @@ class DesktopSourceIterable(SourceIterable):
icon_theme = Gtk.IconTheme.new() icon_theme = Gtk.IconTheme.new()
search_paths = [ search_paths = [
shared.home / ".local" / "share", shared.host_data_dir,
"/run/host/usr/local/share", "/run/host/usr/local/share",
"/run/host/usr/share", "/run/host/usr/share",
"/run/host/usr/share/pixmaps", "/run/host/usr/share/pixmaps",

View File

@@ -233,7 +233,7 @@ class LegendaryIterable(StoreSubSourceIterable):
else: else:
# Heroic native # Heroic native
logging.debug("Using Heroic native <= 2.8 legendary file") logging.debug("Using Heroic native <= 2.8 legendary file")
path = shared.home / ".config" path = shared.host_config_dir
path = path / "legendary" / "installed.json" path = path / "legendary" / "installed.json"
logging.debug("Using Heroic %s installed.json path %s", self.name, path) logging.debug("Using Heroic %s installed.json path %s", self.name, path)
@@ -371,7 +371,7 @@ class HeroicSource(URLExecutableSource):
schema_key="heroic-location", schema_key="heroic-location",
candidates=( candidates=(
shared.config_dir / "heroic", shared.config_dir / "heroic",
shared.home / ".config" / "heroic", shared.host_config_dir / "heroic",
shared.flatpak_dir shared.flatpak_dir
/ "com.heroicgameslauncher.hgl" / "com.heroicgameslauncher.hgl"
/ "config" / "config"

View File

@@ -93,7 +93,7 @@ class ItchSource(URLExecutableSource):
candidates=( candidates=(
shared.flatpak_dir / "io.itch.itch" / "config" / "itch", shared.flatpak_dir / "io.itch.itch" / "config" / "itch",
shared.config_dir / "itch", shared.config_dir / "itch",
shared.home / ".config" / "itch", shared.host_config_dir / "itch",
shared.appdata_dir / "itch", shared.appdata_dir / "itch",
), ),
paths={ paths={

View File

@@ -108,7 +108,7 @@ class LegendarySource(ExecutableFormatSource):
schema_key="legendary-location", schema_key="legendary-location",
candidates=( candidates=(
shared.config_dir / "legendary", shared.config_dir / "legendary",
shared.home / ".config" / "legendary", shared.host_config_dir / "legendary",
), ),
paths={ paths={
"installed.json": LocationSubPath("installed.json"), "installed.json": LocationSubPath("installed.json"),

View File

@@ -110,7 +110,7 @@ class LutrisSource(URLExecutableSource):
candidates=( candidates=(
shared.flatpak_dir / "net.lutris.Lutris" / "data" / "lutris", shared.flatpak_dir / "net.lutris.Lutris" / "data" / "lutris",
shared.data_dir / "lutris", shared.data_dir / "lutris",
shared.home / ".local" / "share" / "lutris", shared.host_data_dir / "lutris",
), ),
paths={ paths={
"pga.db": LocationSubPath("pga.db"), "pga.db": LocationSubPath("pga.db"),
@@ -122,7 +122,7 @@ class LutrisSource(URLExecutableSource):
candidates=( candidates=(
shared.flatpak_dir / "net.lutris.Lutris" / "cache" / "lutris", shared.flatpak_dir / "net.lutris.Lutris" / "cache" / "lutris",
shared.cache_dir / "lutris", shared.cache_dir / "lutris",
shared.home / ".cache" / "lutris", shared.host_cache_dir / "lutris",
), ),
paths={ paths={
"coverart": LocationSubPath("coverart", True), "coverart": LocationSubPath("coverart", True),

View File

@@ -157,7 +157,7 @@ class RetroarchSource(Source):
/ "config" / "config"
/ "retroarch", / "retroarch",
shared.config_dir / "retroarch", shared.config_dir / "retroarch",
shared.home / ".config" / "retroarch", shared.host_config_dir / "retroarch",
# TODO: Windows support, waiting for executable path setting improvement # TODO: Windows support, waiting for executable path setting improvement
# Path("C:\\RetroArch-Win64"), # Path("C:\\RetroArch-Win64"),
# Path("C:\\RetroArch-Win32"), # Path("C:\\RetroArch-Win32"),

View File

@@ -17,8 +17,8 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import os
from enum import IntEnum, auto from enum import IntEnum, auto
from os import getenv
from pathlib import Path from pathlib import Path
from gi.repository import Gdk, Gio, GLib from gi.repository import Gdk, Gio, GLib
@@ -43,19 +43,26 @@ schema = Gio.Settings.new(APP_ID)
state_schema = Gio.Settings.new(APP_ID + ".State") state_schema = Gio.Settings.new(APP_ID + ".State")
home = Path.home() home = Path.home()
data_dir = Path(GLib.get_user_data_dir()) data_dir = Path(GLib.get_user_data_dir())
host_data_dir = Path(getenv("HOST_XDG_DATA_HOME", Path.home() / ".local" / "share"))
config_dir = Path(GLib.get_user_config_dir()) config_dir = Path(GLib.get_user_config_dir())
host_config_dir = Path(getenv("HOST_XDG_CONFIG_HOME", Path.home() / ".config"))
cache_dir = Path(GLib.get_user_cache_dir()) cache_dir = Path(GLib.get_user_cache_dir())
host_cache_dir = Path(getenv("HOST_XDG_CACHE_HOME", Path.home() / ".cache"))
flatpak_dir = home / ".var" / "app" flatpak_dir = home / ".var" / "app"
games_dir = data_dir / "cartridges" / "games" games_dir = data_dir / "cartridges" / "games"
covers_dir = data_dir / "cartridges" / "covers" covers_dir = data_dir / "cartridges" / "covers"
appdata_dir = Path(os.getenv("appdata") or "C:\\Users\\Default\\AppData\\Roaming") appdata_dir = Path(getenv("appdata") or r"C:\Users\Default\AppData\Roaming")
local_appdata_dir = Path( local_appdata_dir = Path(
os.getenv("csidl_local_appdata") or "C:\\Users\\Default\\AppData\\Local" getenv("csidl_local_appdata") or r"C:\Users\Default\AppData\Local"
) )
programfiles32_dir = Path(os.getenv("programfiles(x86)") or "C:\\Program Files (x86)") programfiles32_dir = Path(getenv("programfiles(x86)") or r"C:\Program Files (x86)")
try: try:
scale_factor = max( scale_factor = max(