Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions rare/utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,22 @@ def desktop_link_path(link_name: str, link_type: str) -> Path:
return __link_type[link_type].joinpath(f"{link_name}.{__link_suffix[platform.system()]['link']}")


def get_rare_executable() -> List[str]:
def get_rare_executable(*, external: bool = False) -> List[str]:
"""
Returns the command list to invoke Rare for different platforms and packaging solutions
When used with container based packaging, such as Flatpak or Snap, returns the command
invoke Rare outside of the container

:param external: if True return the command to invoke Rare through Flatpak or Snap, defaults to false
:return: command list
"""
logger.debug(f"Trying to find executable: {sys.executable}, {sys.argv}")

if os.environ.get("SNAP") and external:
return ["snap", "run", "rare"]
if os.environ.get("container") == "flatpak" and external:
return ["flatpak", "run", "io.github.dummerle.rare"]

# lk: detect if nuitka
if "__compiled__" in globals():
executable = [sys.executable]
Expand Down Expand Up @@ -324,7 +338,7 @@ def create_desktop_link(app_name: str, app_title: str = "", link_name: str = "",
logger.info(f"Creating shortcut for {app_title} at {shortcut_path}")

if platform.system() in {"Linux", "FreeBSD"}:
executable = get_rare_executable()
executable = get_rare_executable(external=True)
executable = shlex.join(executable)
if not for_rare:
executable = f"{executable} launch {app_name}"
Expand Down Expand Up @@ -370,3 +384,5 @@ def create_desktop_link(app_name: str, app_title: str = "", link_name: str = "",

shortcut.save()
return True

return False
2 changes: 1 addition & 1 deletion rare/utils/steam_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def add_steam_shortcut(app_name: str, app_title: str) -> SteamShortcut:
logger.info("Removing old Steam shortcut for %s", app_name)
remove_steam_shortcut(app_name)

command = get_rare_executable()
command = get_rare_executable(external=True)
arguments = ["launch", app_name]
if len(command) > 1:
arguments = command[1:] + arguments
Expand Down