From 3af968fee7092c4a31083edbf825c9e1c0431dd0 Mon Sep 17 00:00:00 2001 From: GeoffreyCoulaud Date: Sat, 1 Jul 2023 15:10:40 +0200 Subject: [PATCH 1/3] Simplified source available on --- src/importer/sources/bottles_source.py | 2 +- src/importer/sources/flatpak_source.py | 2 +- src/importer/sources/heroic_source.py | 2 +- src/importer/sources/itch_source.py | 2 +- src/importer/sources/legendary_source.py | 2 +- src/importer/sources/lutris_source.py | 2 +- src/importer/sources/steam_source.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/importer/sources/bottles_source.py b/src/importer/sources/bottles_source.py index 2905fb3..b114ed8 100644 --- a/src/importer/sources/bottles_source.py +++ b/src/importer/sources/bottles_source.py @@ -86,7 +86,7 @@ class BottlesSource(URLExecutableSource): name = "Bottles" iterator_class = BottlesSourceIterator url_format = 'bottles:run/"{bottle_name}"/"{game_name}"' - available_on = set(("linux",)) + available_on = {"linux"} data_location = Location( schema_key="bottles-location", diff --git a/src/importer/sources/flatpak_source.py b/src/importer/sources/flatpak_source.py index d793ecb..726edaf 100644 --- a/src/importer/sources/flatpak_source.py +++ b/src/importer/sources/flatpak_source.py @@ -116,7 +116,7 @@ class FlatpakSource(Source): name = "Flatpak" iterator_class = FlatpakSourceIterator executable_format = "flatpak run {flatpak_id}" - available_on = set(("linux",)) + available_on = {"linux"} data_location = Location( schema_key="flatpak-location", diff --git a/src/importer/sources/heroic_source.py b/src/importer/sources/heroic_source.py index ed501c2..09e97c0 100644 --- a/src/importer/sources/heroic_source.py +++ b/src/importer/sources/heroic_source.py @@ -137,7 +137,7 @@ class HeroicSource(URLExecutableSource): name = "Heroic" iterator_class = HeroicSourceIterator url_format = "heroic://launch/{app_name}" - available_on = set(("linux", "win32")) + available_on = {"linux", "win32"} config_location = Location( schema_key="heroic-location", diff --git a/src/importer/sources/itch_source.py b/src/importer/sources/itch_source.py index 0b11dcb..4863568 100644 --- a/src/importer/sources/itch_source.py +++ b/src/importer/sources/itch_source.py @@ -82,7 +82,7 @@ class ItchSource(URLExecutableSource): name = "Itch" iterator_class = ItchSourceIterator url_format = "itch://caves/{cave_id}/launch" - available_on = set(("linux", "win32")) + available_on = {"linux", "win32"} config_location = Location( schema_key="itch-location", diff --git a/src/importer/sources/legendary_source.py b/src/importer/sources/legendary_source.py index b6b15cb..199ae04 100644 --- a/src/importer/sources/legendary_source.py +++ b/src/importer/sources/legendary_source.py @@ -92,7 +92,7 @@ class LegendarySourceIterator(SourceIterator): class LegendarySource(Source): name = "Legendary" executable_format = "legendary launch {app_name}" - available_on = set(("linux", "win32")) + available_on = {"linux", "win32"} iterator_class = LegendarySourceIterator config_location: Location = Location( diff --git a/src/importer/sources/lutris_source.py b/src/importer/sources/lutris_source.py index 17e4956..8743b22 100644 --- a/src/importer/sources/lutris_source.py +++ b/src/importer/sources/lutris_source.py @@ -93,7 +93,7 @@ class LutrisSource(URLExecutableSource): name = "Lutris" iterator_class = LutrisSourceIterator url_format = "lutris:rungameid/{game_id}" - available_on = set(("linux",)) + available_on = {"linux"} # FIXME possible bug: location picks ~/.var... and cache_lcoation picks ~/.local... diff --git a/src/importer/sources/steam_source.py b/src/importer/sources/steam_source.py index 13d99a7..921090d 100644 --- a/src/importer/sources/steam_source.py +++ b/src/importer/sources/steam_source.py @@ -111,7 +111,7 @@ class SteamSourceIterator(SourceIterator): class SteamSource(URLExecutableSource): name = "Steam" - available_on = set(("linux", "win32")) + available_on = {"linux", "win32"} iterator_class = SteamSourceIterator url_format = "steam://rungameid/{game_id}" From fb0c47c1f1b1c369032e2feefba9c5c3bf53bdba Mon Sep 17 00:00:00 2001 From: GeoffreyCoulaud Date: Sat, 1 Jul 2023 15:17:12 +0200 Subject: [PATCH 2/3] Re added hardcoded candidates for linux - Real fix would be to get the XDG_*_DIR --- src/importer/sources/bottles_source.py | 1 + src/importer/sources/lutris_source.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/importer/sources/bottles_source.py b/src/importer/sources/bottles_source.py index b114ed8..5b52fe7 100644 --- a/src/importer/sources/bottles_source.py +++ b/src/importer/sources/bottles_source.py @@ -93,6 +93,7 @@ class BottlesSource(URLExecutableSource): candidates=( "~/.var/app/com.usebottles.bottles/data/bottles/", shared.data_dir / "bottles/", + "~/.local/share/bottles", ), paths={ "library.yml": (False, "library.yml"), diff --git a/src/importer/sources/lutris_source.py b/src/importer/sources/lutris_source.py index 8743b22..9a1d16d 100644 --- a/src/importer/sources/lutris_source.py +++ b/src/importer/sources/lutris_source.py @@ -102,6 +102,7 @@ class LutrisSource(URLExecutableSource): candidates=( "~/.var/app/net.lutris.Lutris/data/lutris/", shared.data_dir / "lutris", + "~/.local/share/lutris", ), paths={ "pga.db": (False, "pga.db"), @@ -113,6 +114,7 @@ class LutrisSource(URLExecutableSource): candidates=( "~/.var/app/net.lutris.Lutris/cache/lutris/", shared.cache_dir / "lutris", + "~/.cache/lutris", ), paths={ "coverart": (True, "coverart"), From 4a204442b5d8ba2e918f8c2605d72e483bf35efd Mon Sep 17 00:00:00 2001 From: GeoffreyCoulaud Date: Sat, 1 Jul 2023 15:53:52 +0200 Subject: [PATCH 3/3] Using new shared paths in sources --- src/importer/sources/bottles_source.py | 4 ++-- src/importer/sources/heroic_source.py | 3 ++- src/importer/sources/itch_source.py | 3 ++- src/importer/sources/legendary_source.py | 5 ++++- src/importer/sources/lutris_source.py | 8 ++++---- src/importer/sources/steam_source.py | 4 ++-- src/shared.py.in | 22 ++++++---------------- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/importer/sources/bottles_source.py b/src/importer/sources/bottles_source.py index 5b52fe7..c1af459 100644 --- a/src/importer/sources/bottles_source.py +++ b/src/importer/sources/bottles_source.py @@ -91,9 +91,9 @@ class BottlesSource(URLExecutableSource): data_location = Location( schema_key="bottles-location", candidates=( - "~/.var/app/com.usebottles.bottles/data/bottles/", + shared.flatpak_dir / "com.usebottles.bottles" / "data" / "bottles", shared.data_dir / "bottles/", - "~/.local/share/bottles", + shared.home / ".local" / "share" / "bottles", ), paths={ "library.yml": (False, "library.yml"), diff --git a/src/importer/sources/heroic_source.py b/src/importer/sources/heroic_source.py index 09e97c0..9048ca8 100644 --- a/src/importer/sources/heroic_source.py +++ b/src/importer/sources/heroic_source.py @@ -142,8 +142,9 @@ class HeroicSource(URLExecutableSource): config_location = Location( schema_key="heroic-location", candidates=( - "~/.var/app/com.heroicgameslauncher.hgl/config/heroic/", + shared.flatpak_dir / "com.heroicgameslauncher.hgl" / "config" / "heroic", shared.config_dir / "heroic", + shared.home / ".config" / "heroic", shared.appdata_dir / "heroic", ), paths={ diff --git a/src/importer/sources/itch_source.py b/src/importer/sources/itch_source.py index 4863568..841c2e0 100644 --- a/src/importer/sources/itch_source.py +++ b/src/importer/sources/itch_source.py @@ -87,8 +87,9 @@ class ItchSource(URLExecutableSource): config_location = Location( schema_key="itch-location", candidates=( - "~/.var/app/io.itch.itch/config/itch/", + shared.flatpak_dir / "io.itch.itch" / "config" / "itch", shared.config_dir / "itch", + shared.home / ".config" / "itch", shared.appdata_dir / "itch", ), paths={"butler.db": (False, "db/butler.db")}, diff --git a/src/importer/sources/legendary_source.py b/src/importer/sources/legendary_source.py index 199ae04..2882e92 100644 --- a/src/importer/sources/legendary_source.py +++ b/src/importer/sources/legendary_source.py @@ -97,7 +97,10 @@ class LegendarySource(Source): iterator_class = LegendarySourceIterator config_location: Location = Location( schema_key="legendary-location", - candidates=(shared.config_dir / "legendary",), + candidates=( + shared.config_dir / "legendary", + shared.home / ".config" / "legendary", + ), paths={ "installed.json": (False, "installed.json"), "metadata": (True, "metadata"), diff --git a/src/importer/sources/lutris_source.py b/src/importer/sources/lutris_source.py index 9a1d16d..ad0bc80 100644 --- a/src/importer/sources/lutris_source.py +++ b/src/importer/sources/lutris_source.py @@ -100,9 +100,9 @@ class LutrisSource(URLExecutableSource): data_location = Location( schema_key="lutris-location", candidates=( - "~/.var/app/net.lutris.Lutris/data/lutris/", + shared.flatpak_dir / "net.lutris.Lutris" / "data" / "lutris", shared.data_dir / "lutris", - "~/.local/share/lutris", + shared.home / ".local" / "share" / "lutris", ), paths={ "pga.db": (False, "pga.db"), @@ -112,9 +112,9 @@ class LutrisSource(URLExecutableSource): cache_location = Location( schema_key="lutris-cache-location", candidates=( - "~/.var/app/net.lutris.Lutris/cache/lutris/", + shared.flatpak_dir / "net.lutris.Lutris" / "cache" / "lutris", shared.cache_dir / "lutris", - "~/.cache/lutris", + shared.home / ".cache" / "lutris", ), paths={ "coverart": (True, "coverart"), diff --git a/src/importer/sources/steam_source.py b/src/importer/sources/steam_source.py index 921090d..ff60d86 100644 --- a/src/importer/sources/steam_source.py +++ b/src/importer/sources/steam_source.py @@ -118,9 +118,9 @@ class SteamSource(URLExecutableSource): data_location = Location( schema_key="steam-location", candidates=( - "~/.var/app/com.valvesoftware.Steam/data/Steam/", + shared.flatpak_dir / "com.valvesoftware.Steam" / "data" / "Steam", shared.data_dir / "Steam", - "~/.steam", + shared.home / ".steam", shared.programfiles32_dir / "Steam", ), paths={ diff --git a/src/shared.py.in b/src/shared.py.in index 3be3fef..bfa882c 100644 --- a/src/shared.py.in +++ b/src/shared.py.in @@ -20,7 +20,7 @@ import os from pathlib import Path -from gi.repository import Gdk, Gio +from gi.repository import Gdk, Gio, GLib APP_ID = "@APP_ID@" VERSION = "@VERSION@" @@ -31,21 +31,11 @@ SPEC_VERSION = 1.5 # The version of the game_id.json spec schema = Gio.Settings.new(APP_ID) state_schema = Gio.Settings.new(APP_ID + ".State") -data_dir = ( - Path(os.getenv("XDG_DATA_HOME")) - if "XDG_DATA_HOME" in os.environ - else Path.home() / ".local" / "share" -) -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" -) +home = Path.home() +data_dir = Path(GLib.get_user_data_dir()) +config_dir = Path(GLib.get_user_config_dir()) +cache_dir = Path(GLib.get_user_config_dir()) +flatpak_dir = home / ".var" / "app" games_dir = data_dir / "cartridges" / "games" covers_dir = data_dir / "cartridges" / "covers"