diff --git a/hu.kramo.Cartridges.json b/hu.kramo.Cartridges.json index 6f17d6a..8f5bb2e 100644 --- a/hu.kramo.Cartridges.json +++ b/hu.kramo.Cartridges.json @@ -11,6 +11,9 @@ "--socket=wayland", "--talk-name=org.freedesktop.Flatpak", "--filesystem=~/.steam/steam/", + "--filesystem=xdg-config/heroic/", + "--filesystem=xdg-data/bottles/", + "--filesystem=~/.var/app/com.valvesoftware.Steam/data/Steam/", "--filesystem=~/.var/app/com.heroicgameslauncher.hgl/config/heroic/", "--filesystem=~/.var/app/com.usebottles.bottles/data/bottles/" ], diff --git a/src/utils/bottles_parser.py b/src/utils/bottles_parser.py index 826a921..2303286 100644 --- a/src/utils/bottles_parser.py +++ b/src/utils/bottles_parser.py @@ -26,27 +26,33 @@ def bottles_parser(parent_widget, action): from .save_cover import save_cover schema = parent_widget.schema - bottles_dir = os.path.expanduser(os.path.join(schema.get_string("bottles-location"))) + bottles_dir = os.path.expanduser(schema.get_string("bottles-location")) def bottles_not_found(): - filechooser = Gtk.FileDialog.new() + if os.path.exists(os.path.expanduser("~/.var/app/com.usebottles.bottles/data/bottles/")): + schema.set_string("bottles-location", "~/.var/app/com.usebottles.bottles/data/bottles/") + action(None, None) + elif os.path.exists(os.path.join(os.environ.get("XDG_DATA_HOME"), "bottles")): + schema.set_string("bottles-location", os.path.join(os.environ.get("XDG_DATA_HOME"), "bottles")) + action(None, None) + else: + filechooser = Gtk.FileDialog.new() - def set_bottles_dir(source, result, _): - try: - schema.set_string("bottles-location", filechooser.select_folder_finish(result).get_path()) - bottles_dir = bottles_dir = os.path.join(schema.get_string("bottles-location")) - action(None, None) - except GLib.GError: - return + def set_bottles_dir(source, result, _): + try: + schema.set_string("bottles-location", filechooser.select_folder_finish(result).get_path()) + action(None, None) + except GLib.GError: + return - def choose_folder(widget): - filechooser.select_folder(parent_widget, None, set_bottles_dir, None) + def choose_folder(widget): + filechooser.select_folder(parent_widget, None, set_bottles_dir, None) - def response(widget, response): - if response == "choose_folder": - choose_folder(widget) + def response(widget, response): + if response == "choose_folder": + choose_folder(widget) - create_dialog(parent_widget, _("Couldn't Import Games"), _("Bottles directory cannot be found."), "choose_folder", _("Set Bottles Location")).connect("response", response) + create_dialog(parent_widget, _("Couldn't Import Games"), _("Bottles directory cannot be found."), "choose_folder", _("Set Bottles Location")).connect("response", response) if os.path.isfile(os.path.join(bottles_dir, "library.yml")): pass @@ -54,6 +60,8 @@ def bottles_parser(parent_widget, action): bottles_not_found() return {} + bottles_dir = os.path.expanduser(schema.get_string("bottles-location")) + datatypes = ["path", "id", "name", "thumbnail"] bottles_games = {} current_time = int(time.time()) diff --git a/src/utils/heroic_parser.py b/src/utils/heroic_parser.py index a1c91ff..03795cf 100644 --- a/src/utils/heroic_parser.py +++ b/src/utils/heroic_parser.py @@ -26,28 +26,33 @@ def heroic_parser(parent_widget, action): from .save_cover import save_cover schema = parent_widget.schema - heroic_dir = os.path.expanduser(os.path.join(schema.get_string("heroic-location"))) + heroic_dir = os.path.expanduser(schema.get_string("heroic-location")) def heroic_not_found(): - filechooser = Gtk.FileDialog.new() + if os.path.exists(os.path.expanduser("~/.var/app/com.heroicgameslauncher.hgl/config/heroic/")): + schema.set_string("heroic-location", "~/.var/app/com.heroicgameslauncher.hgl/config/heroic/") + action(None, None) + elif os.path.exists(os.path.join(os.environ.get("XDG_CONFIG_HOME"), "heroic")): + schema.set_string("heroic-location", os.path.join(os.environ.get("XDG_CONFIG_HOME"), "heroic")) + action(None, None) + else: + filechooser = Gtk.FileDialog.new() - def set_heroic_dir(source, result, _): - try: - schema.set_string("heroic-location", filechooser.select_folder_finish(result).get_path()) - heroic_dir = heroic_dir = os.path.join(schema.get_string("heroic-location")) - action(None, None) - except GLib.GError: - return + def set_heroic_dir(source, result, _): + try: + schema.set_string("heroic-location", filechooser.select_folder_finish(result).get_path()) + action(None, None) + except GLib.GError: + return - def choose_folder(widget): - filechooser.select_folder(parent_widget, None, set_heroic_dir, None) + def choose_folder(widget): + filechooser.select_folder(parent_widget, None, set_heroic_dir, None) - def response(widget, response): - if response == "choose_folder": - choose_folder(widget) + def response(widget, response): + if response == "choose_folder": + choose_folder(widget) - create_dialog(parent_widget, _("Couldn't Import Games"), _("Heroic directory cannot be found."), - "choose_folder", _("Set Heroic Location")).connect("response", response) + create_dialog(parent_widget, _("Couldn't Import Games"), _("Heroic directory cannot be found."), "choose_folder", _("Set Heroic Location")).connect("response", response) if os.path.exists(os.path.join(heroic_dir, "config.json")): pass @@ -55,6 +60,8 @@ def heroic_parser(parent_widget, action): heroic_not_found() return {} + heroic_dir = os.path.expanduser(schema.get_string("heroic-location")) + heroic_games = {} current_time = int(time.time()) diff --git a/src/utils/steam_parser.py b/src/utils/steam_parser.py index 88300fb..f0d9f54 100644 --- a/src/utils/steam_parser.py +++ b/src/utils/steam_parser.py @@ -26,27 +26,33 @@ def steam_parser(parent_widget, action): from .save_cover import save_cover schema = parent_widget.schema - steam_dir = os.path.expanduser(os.path.join(schema.get_string("steam-location"))) + steam_dir = os.path.expanduser(schema.get_string("steam-location")) def steam_not_found(): - filechooser = Gtk.FileDialog.new() + if os.path.exists(os.path.expanduser("~/.var/app/com.valvesoftware.Steam/data/Steam/")): + schema.set_string("steam-location", "~/.var/app/com.valvesoftware.Steam/data/Steam/") + action(None, None) + elif os.path.exists(os.path.expanduser("~/.steam/steam/")): + schema.set_string("steam-location", "~/.steam/steam/") + action(None, None) + else: + filechooser = Gtk.FileDialog.new() - def set_steam_dir(source, result, _): - try: - schema.set_string("steam-location", filechooser.select_folder_finish(result).get_path()) - steam_dir = steam_dir = os.path.join(schema.get_string("steam-location")) - action(None, None) - except GLib.GError: - return + def set_steam_dir(source, result, _): + try: + schema.set_string("steam-location", filechooser.select_folder_finish(result).get_path()) + action(None, None) + except GLib.GError: + return - def choose_folder(widget): - filechooser.select_folder(parent_widget, None, set_steam_dir, None) + def choose_folder(widget): + filechooser.select_folder(parent_widget, None, set_steam_dir, None) - def response(widget, response): - if response == "choose_folder": - choose_folder(widget) + def response(widget, response): + if response == "choose_folder": + choose_folder(widget) - create_dialog(parent_widget, _("Couldn't Import Games"), _("Steam directory cannot be found."), "choose_folder", _("Set Steam Location")).connect("response", response) + create_dialog(parent_widget, _("Couldn't Import Games"), _("Steam directory cannot be found."), "choose_folder", _("Set Steam Location")).connect("response", response) if os.path.exists(os.path.join(steam_dir, "steamapps")): pass @@ -58,7 +64,7 @@ def steam_parser(parent_widget, action): steam_not_found() return {} - steam_dir = schema.get_string("steam-location") + steam_dir = os.path.expanduser(schema.get_string("steam-location")) appmanifests = [] datatypes = ["appid", "name"]