Merge pull request #127 from kra-mo/sources-paths-fix

Sources paths fix
This commit is contained in:
Geoffrey Coulaud
2023-07-01 17:10:47 +02:00
committed by GitHub
8 changed files with 29 additions and 31 deletions

View File

@@ -86,13 +86,14 @@ class BottlesSource(URLExecutableSource):
name = "Bottles" name = "Bottles"
iterator_class = BottlesSourceIterator iterator_class = BottlesSourceIterator
url_format = 'bottles:run/"{bottle_name}"/"{game_name}"' url_format = 'bottles:run/"{bottle_name}"/"{game_name}"'
available_on = set(("linux",)) available_on = {"linux"}
data_location = Location( data_location = Location(
schema_key="bottles-location", schema_key="bottles-location",
candidates=( candidates=(
"~/.var/app/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",
), ),
paths={ paths={
"library.yml": (False, "library.yml"), "library.yml": (False, "library.yml"),

View File

@@ -116,7 +116,7 @@ class FlatpakSource(Source):
name = "Flatpak" name = "Flatpak"
iterator_class = FlatpakSourceIterator iterator_class = FlatpakSourceIterator
executable_format = "flatpak run {flatpak_id}" executable_format = "flatpak run {flatpak_id}"
available_on = set(("linux",)) available_on = {"linux"}
data_location = Location( data_location = Location(
schema_key="flatpak-location", schema_key="flatpak-location",

View File

@@ -137,13 +137,14 @@ class HeroicSource(URLExecutableSource):
name = "Heroic" name = "Heroic"
iterator_class = HeroicSourceIterator iterator_class = HeroicSourceIterator
url_format = "heroic://launch/{app_name}" url_format = "heroic://launch/{app_name}"
available_on = set(("linux", "win32")) available_on = {"linux", "win32"}
config_location = Location( config_location = Location(
schema_key="heroic-location", schema_key="heroic-location",
candidates=( candidates=(
"~/.var/app/com.heroicgameslauncher.hgl/config/heroic/", shared.flatpak_dir / "com.heroicgameslauncher.hgl" / "config" / "heroic",
shared.config_dir / "heroic", shared.config_dir / "heroic",
shared.home / ".config" / "heroic",
shared.appdata_dir / "heroic", shared.appdata_dir / "heroic",
), ),
paths={ paths={

View File

@@ -82,13 +82,14 @@ class ItchSource(URLExecutableSource):
name = "Itch" name = "Itch"
iterator_class = ItchSourceIterator iterator_class = ItchSourceIterator
url_format = "itch://caves/{cave_id}/launch" url_format = "itch://caves/{cave_id}/launch"
available_on = set(("linux", "win32")) available_on = {"linux", "win32"}
config_location = Location( config_location = Location(
schema_key="itch-location", schema_key="itch-location",
candidates=( candidates=(
"~/.var/app/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.appdata_dir / "itch", shared.appdata_dir / "itch",
), ),
paths={"butler.db": (False, "db/butler.db")}, paths={"butler.db": (False, "db/butler.db")},

View File

@@ -92,12 +92,15 @@ class LegendarySourceIterator(SourceIterator):
class LegendarySource(Source): class LegendarySource(Source):
name = "Legendary" name = "Legendary"
executable_format = "legendary launch {app_name}" executable_format = "legendary launch {app_name}"
available_on = set(("linux", "win32")) available_on = {"linux", "win32"}
iterator_class = LegendarySourceIterator iterator_class = LegendarySourceIterator
config_location: Location = Location( config_location: Location = Location(
schema_key="legendary-location", schema_key="legendary-location",
candidates=(shared.config_dir / "legendary",), candidates=(
shared.config_dir / "legendary",
shared.home / ".config" / "legendary",
),
paths={ paths={
"installed.json": (False, "installed.json"), "installed.json": (False, "installed.json"),
"metadata": (True, "metadata"), "metadata": (True, "metadata"),

View File

@@ -93,15 +93,16 @@ class LutrisSource(URLExecutableSource):
name = "Lutris" name = "Lutris"
iterator_class = LutrisSourceIterator iterator_class = LutrisSourceIterator
url_format = "lutris:rungameid/{game_id}" url_format = "lutris:rungameid/{game_id}"
available_on = set(("linux",)) available_on = {"linux"}
# FIXME possible bug: location picks ~/.var... and cache_lcoation picks ~/.local... # FIXME possible bug: location picks ~/.var... and cache_lcoation picks ~/.local...
data_location = Location( data_location = Location(
schema_key="lutris-location", schema_key="lutris-location",
candidates=( candidates=(
"~/.var/app/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",
), ),
paths={ paths={
"pga.db": (False, "pga.db"), "pga.db": (False, "pga.db"),
@@ -111,8 +112,9 @@ class LutrisSource(URLExecutableSource):
cache_location = Location( cache_location = Location(
schema_key="lutris-cache-location", schema_key="lutris-cache-location",
candidates=( candidates=(
"~/.var/app/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",
), ),
paths={ paths={
"coverart": (True, "coverart"), "coverart": (True, "coverart"),

View File

@@ -111,16 +111,16 @@ class SteamSourceIterator(SourceIterator):
class SteamSource(URLExecutableSource): class SteamSource(URLExecutableSource):
name = "Steam" name = "Steam"
available_on = set(("linux", "win32")) available_on = {"linux", "win32"}
iterator_class = SteamSourceIterator iterator_class = SteamSourceIterator
url_format = "steam://rungameid/{game_id}" url_format = "steam://rungameid/{game_id}"
data_location = Location( data_location = Location(
schema_key="steam-location", schema_key="steam-location",
candidates=( candidates=(
"~/.var/app/com.valvesoftware.Steam/data/Steam/", shared.flatpak_dir / "com.valvesoftware.Steam" / "data" / "Steam",
shared.data_dir / "Steam", shared.data_dir / "Steam",
"~/.steam", shared.home / ".steam",
shared.programfiles32_dir / "Steam", shared.programfiles32_dir / "Steam",
), ),
paths={ paths={

View File

@@ -20,7 +20,7 @@
import os import os
from pathlib import Path from pathlib import Path
from gi.repository import Gdk, Gio from gi.repository import Gdk, Gio, GLib
APP_ID = "@APP_ID@" APP_ID = "@APP_ID@"
VERSION = "@VERSION@" VERSION = "@VERSION@"
@@ -31,21 +31,11 @@ SPEC_VERSION = 1.5 # The version of the game_id.json spec
schema = Gio.Settings.new(APP_ID) schema = Gio.Settings.new(APP_ID)
state_schema = Gio.Settings.new(APP_ID + ".State") state_schema = Gio.Settings.new(APP_ID + ".State")
data_dir = ( home = Path.home()
Path(os.getenv("XDG_DATA_HOME")) data_dir = Path(GLib.get_user_data_dir())
if "XDG_DATA_HOME" in os.environ config_dir = Path(GLib.get_user_config_dir())
else Path.home() / ".local" / "share" cache_dir = Path(GLib.get_user_config_dir())
) flatpak_dir = home / ".var" / "app"
config_dir = (
Path(os.getenv("XDG_CONFIG_HOME"))
if "XDG_CONFIG_HOME" in os.environ
else Path.home() / ".config"
)
cache_dir = (
Path(os.getenv("XDG_CACHE_HOME"))
if "XDG_CACHE_HOME" in os.environ
else Path.home() / ".cache"
)
games_dir = data_dir / "cartridges" / "games" games_dir = data_dir / "cartridges" / "games"
covers_dir = data_dir / "cartridges" / "covers" covers_dir = data_dir / "cartridges" / "covers"