From c69667e6d5f231764bf2437b4acb9750541bd743 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:56:49 -0700 Subject: [PATCH 01/13] umu_run: default opts as a list --- umu/umu_run.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index a479fe2df..0319fff38 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -371,7 +371,7 @@ def build_command( env: dict[str, str], local: Path, command: list[str], - opts: list[str] = None, + opts: list[str] = [], ) -> list[str]: """Build the command to be executed.""" verb: str = env["PROTON_VERB"] @@ -395,20 +395,6 @@ def build_command( # Usage: ./winetricks [options] [command|verb|path-to-verb] ... opts = ["-q", *opts] - if opts: - command.extend( - [ - local.joinpath("umu").as_posix(), - "--verb", - verb, - "--", - Path(env.get("PROTONPATH")).joinpath("proton").as_posix(), - verb, - env.get("EXE"), - *opts, - ], - ) - return command command.extend( [ local.joinpath("umu").as_posix(), @@ -418,6 +404,7 @@ def build_command( Path(env.get("PROTONPATH")).joinpath("proton").as_posix(), verb, env.get("EXE"), + *opts, ], ) From 7827ecb1bd6cd0aefdd9f0b14a7704b858c0349a Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:59:33 -0700 Subject: [PATCH 02/13] umu_run: add environment variable to disable runtime - Intended for debugging purposes and Flatpaks, UMU_NO_RUNTIME will configure the launcher to disable all or parts of the runtime. The value 'pressure-vessel' will be the default when running the launcher within a Flatpak environment to workaround the game window not displaying within the SteamOS gamescope session --- umu/umu_run.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/umu/umu_run.py b/umu/umu_run.py index 0319fff38..7aad6e623 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -308,6 +308,17 @@ def set_env( "" if os.environ.get("UMU_LOG") == "debug" else "1" ) + # Runtime + # Currently, running games when using the Steam Runtime in a Flatpak + # environment will cause the game window to not display within the SteamOS + # gamescope session. Note, this is a workaround until the runtime is built + # or the issue is fixed upstream. + # See https://github.com/ValveSoftware/gamescope/issues/1341 + if FLATPAK_PATH: + env["UMU_NO_RUNTIME"] = ( + os.environ.get("UMU_NO_RUNTIME") or "pressure-vessel" + ) + return env @@ -376,6 +387,28 @@ def build_command( """Build the command to be executed.""" verb: str = env["PROTON_VERB"] + if env.get("UMU_NO_RUNTIME") == "1": + log.warning("Runtime Platform disabled") + command.extend( + [ + env.get("EXE"), + *opts, + ], + ) + return command + + if env.get("UMU_NO_RUNTIME") == "pressure-vessel": + log.warning("Using Proton without Runtime Platform") + command.extend( + [ + Path(env.get("PROTONPATH")).joinpath("proton").as_posix(), + verb, + env.get("EXE"), + *opts, + ], + ) + return command + # Raise an error if the _v2-entry-point cannot be found if not local.joinpath("umu").is_file(): err: str = ( @@ -493,6 +526,7 @@ def main() -> int: # noqa: D103 "UMU_ID": "", "ULWGL_ID": "", "UMU_ZENITY": "", + "UMU_NO_RUNTIME": "", } command: list[str] = [] opts: list[str] = [] From 1fca7b70625031a9234e8165896a1ef0ee142395 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 20:00:27 -0700 Subject: [PATCH 03/13] docs: update environment variables --- docs/umu.1.scd | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/umu.1.scd b/docs/umu.1.scd index 8c554a834..2448557e8 100644 --- a/docs/umu.1.scd +++ b/docs/umu.1.scd @@ -163,6 +163,13 @@ _PROTON_VERB_ _UMU_ZENITY_ Optional. Creates a *zenity*[5] popup window when downloading large files. +_UMU_NO_RUNTIME_ + Optional and only applicable Flatpak applications. Disables the usage of the *Steam Linux Runtime*[6] (SLR). + + Set to _1_ to disable the entirety of the SLR or _pressure-vessel_ to only disable Pressure Vessel and the container runtime. + + Defaults to _pressure-vessel_. + # SEE ALSO _umu_(5), _winetricks_(1), _zenity_(1) @@ -174,6 +181,7 @@ _umu_(5), _winetricks_(1), _zenity_(1) . https://github.com/Open-Wine-Components/umu-protonfixes . https://github.com/Open-Wine-Components/umu-database . https://gitlab.gnome.org/GNOME/zenity +. https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/container-runtime.md # AUTHORS From 938fef343cd40e8a3e8db9a8c6c5054b0e71aac2 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:11:54 -0700 Subject: [PATCH 04/13] umu_util: add function to check if host device is steam deck --- umu/umu_util.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/umu/umu_util.py b/umu/umu_util.py index 634f3c917..fb290ccc1 100644 --- a/umu/umu_util.py +++ b/umu/umu_util.py @@ -120,3 +120,24 @@ def is_winetricks_verb( return False return True + + +@lru_cache +def is_steamdeck() -> bool: + """Determine if the host device is a Steam Deck by its CPU model.""" + cpu_info: Path = Path("/proc/cpuinfo") + is_sd: bool = False + sd_models: set[str] = {"AMD Custom APU 0405", "AMD Custom APU 0932"} + + if not cpu_info.is_file(): + return is_sd + + with cpu_info.open(mode="r", encoding="utf-8") as file: + for line in file: + if line.startswith("model name"): + _: str = line[line.find(":") + 1 :].strip() + if _ in sd_models: + is_sd = True + break + + return is_sd From 5a19c5a3874bbbdfa36a7fad6a4a4ce8595b4f52 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:18:43 -0700 Subject: [PATCH 05/13] umu_run: fix logic when disabling the runtime - Forcibly disable the runtime when using a Flatpak in SteamOS gamescope session if UMU_NO_RUNTIME is not set. --- umu/umu_run.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index 7aad6e623..f8a4f6a97 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -28,7 +28,12 @@ from umu_plugins import set_env_toml from umu_proton import Proton, get_umu_proton from umu_runtime import setup_umu -from umu_util import get_libc, is_installed_verb, is_winetricks_verb +from umu_util import ( + get_libc, + is_installed_verb, + is_steamdeck, + is_winetricks_verb, +) THREAD_POOL: ThreadPoolExecutor = ThreadPoolExecutor() @@ -309,15 +314,23 @@ def set_env( ) # Runtime + if os.environ.get("UMU_NO_RUNTIME"): + env["UMU_NO_RUNTIME"] = os.environ.get("UMU_NO_RUNTIME") or "" + # Currently, running games when using the Steam Runtime in a Flatpak # environment will cause the game window to not display within the SteamOS # gamescope session. Note, this is a workaround until the runtime is built # or the issue is fixed upstream. # See https://github.com/ValveSoftware/gamescope/issues/1341 - if FLATPAK_PATH: - env["UMU_NO_RUNTIME"] = ( - os.environ.get("UMU_NO_RUNTIME") or "pressure-vessel" - ) + if ( + not os.environ.get("UMU_NO_RUNTIME") + and FLATPAK_PATH + and is_steamdeck() + and os.environ.get("XDG_CURRENT_DESKTOP") == "gamescope" + ): + log.debug("SteamOS gamescope session detected") + log.debug("Disabling Pressure Vessel and container runtime") + env["UMU_NO_RUNTIME"] = "pressure-vessel" return env From 2700d83a28116da9271bc38545c98c214992a26c Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:20:14 -0700 Subject: [PATCH 06/13] umu_run: only log warning if not in steamos gamescope session --- umu/umu_run.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index f8a4f6a97..da9a04eb8 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -410,8 +410,15 @@ def build_command( ) return command - if env.get("UMU_NO_RUNTIME") == "pressure-vessel": + # Log the warning when running games within SteamOS gamescope session + if ( + env.get("UMU_NO_RUNTIME") == "pressure-vessel" + and not is_steamdeck() + and os.environ.get("XDG_CURRENT_DESKTOP") != "gamescope" + ): log.warning("Using Proton without Runtime Platform") + + if env.get("UMU_NO_RUNTIME") == "pressure-vessel": command.extend( [ Path(env.get("PROTONPATH")).joinpath("proton").as_posix(), From 5f26effa3964637fe1a61942f67941f2e2070a43 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:44:12 -0700 Subject: [PATCH 07/13] umu_run: update comments --- umu/umu_run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index da9a04eb8..6ac655598 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -400,6 +400,8 @@ def build_command( """Build the command to be executed.""" verb: str = env["PROTON_VERB"] + # Will run the game w/o Proton, effectively running the game as is. This + # option is intended for debugging purposes, and is otherwise useless if env.get("UMU_NO_RUNTIME") == "1": log.warning("Runtime Platform disabled") command.extend( @@ -410,7 +412,7 @@ def build_command( ) return command - # Log the warning when running games within SteamOS gamescope session + # Only log the warning when running games within SteamOS gamescope session if ( env.get("UMU_NO_RUNTIME") == "pressure-vessel" and not is_steamdeck() From 329ca4a81f54ec488c05fc48be3af9f8bef39be7 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:50:14 -0700 Subject: [PATCH 08/13] umu_run: update logic --- umu/umu_run.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index 6ac655598..bc45c578c 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -314,8 +314,7 @@ def set_env( ) # Runtime - if os.environ.get("UMU_NO_RUNTIME"): - env["UMU_NO_RUNTIME"] = os.environ.get("UMU_NO_RUNTIME") or "" + env["UMU_NO_RUNTIME"] = os.environ.get("UMU_NO_RUNTIME") or "" # Currently, running games when using the Steam Runtime in a Flatpak # environment will cause the game window to not display within the SteamOS From b468d75a4b21a767a8b9c344382e58b5a872c849 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:04:00 -0700 Subject: [PATCH 09/13] umu_test: add test for is_steamdeck --- umu/umu_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/umu/umu_test.py b/umu/umu_test.py index 337e4b48a..e08f6ce6a 100644 --- a/umu/umu_test.py +++ b/umu/umu_test.py @@ -179,6 +179,12 @@ def tearDown(self): if self.test_winepfx.exists(): rmtree(self.test_winepfx.as_posix()) + def test_is_steamdeck(self): + """Test is_steamdeck.""" + self.assertIsInstance( + umu_util.is_steamdeck(), bool, "Expected a boolean" + ) + def test_is_installed_verb_noverb(self): """Test is_installed_verb when passed an empty verb.""" verb = [] From aacb3c48ae7dc2bb48a231981b6fc4c7467f5b03 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:04:52 -0700 Subject: [PATCH 10/13] umu_test: update set_env test with UMU_NO_RUNTIME --- umu/umu_test.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/umu/umu_test.py b/umu/umu_test.py index e08f6ce6a..bfbc0a069 100644 --- a/umu/umu_test.py +++ b/umu/umu_test.py @@ -51,6 +51,7 @@ def setUp(self): "LD_PRELOAD": "", "WINEDLLPATH": "", "WINETRICKS_SUPER_QUIET": "", + "UMU_NO_RUNTIME": "", } self.user = getpwuid(os.getuid()).pw_name self.test_opts = "-foo -bar" @@ -1648,6 +1649,7 @@ def test_set_env(self): os.environ["GAMEID"] = test_str os.environ["STORE"] = test_str os.environ["PROTON_VERB"] = self.test_verb + os.environ["UMU_NO_RUNTIME"] = "pressure-vessel" # Args result = umu_run.parse_args() self.assertIsInstance(result, tuple, "Expected a tuple") @@ -1761,6 +1763,11 @@ def test_set_env(self): self.env["STEAM_COMPAT_TOOL_PATHS"], "Expected STEAM_COMPAT_MOUNTS to be set", ) + self.assertEqual( + self.env["UMU_NO_RUNTIME"], + os.environ["UMU_NO_RUNTIME"], + "Expected UMU_NO_RUNTIME to be set", + ) def test_set_env_winetricks(self): """Test set_env when using winetricks.""" From 3d3b8064efaefb9ff6b98ff57993e8ef34b86018 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:08:57 -0700 Subject: [PATCH 11/13] umu_run: update logic --- umu/umu_run.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index bc45c578c..22156eec2 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -314,7 +314,8 @@ def set_env( ) # Runtime - env["UMU_NO_RUNTIME"] = os.environ.get("UMU_NO_RUNTIME") or "" + if FLATPAK_PATH: + env["UMU_NO_RUNTIME"] = os.environ.get("UMU_NO_RUNTIME") or "" # Currently, running games when using the Steam Runtime in a Flatpak # environment will cause the game window to not display within the SteamOS From fad67f840da3097fe5b83df24df37a38f1abcab0 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:19:25 -0700 Subject: [PATCH 12/13] docs: fix typo --- docs/umu.1.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/umu.1.scd b/docs/umu.1.scd index 2448557e8..3127b64a1 100644 --- a/docs/umu.1.scd +++ b/docs/umu.1.scd @@ -164,7 +164,7 @@ _UMU_ZENITY_ Optional. Creates a *zenity*[5] popup window when downloading large files. _UMU_NO_RUNTIME_ - Optional and only applicable Flatpak applications. Disables the usage of the *Steam Linux Runtime*[6] (SLR). + Optional and only applicable to Flatpak applications. Disables the usage of the *Steam Linux Runtime*[6] (SLR). Set to _1_ to disable the entirety of the SLR or _pressure-vessel_ to only disable Pressure Vessel and the container runtime. From cf02b1ed46953ce8c0616a4d37ae76394c7304bf Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:20:44 -0700 Subject: [PATCH 13/13] Revert "umu_test: update set_env test with UMU_NO_RUNTIME" This reverts commit aacb3c48ae7dc2bb48a231981b6fc4c7467f5b03. --- umu/umu_test.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/umu/umu_test.py b/umu/umu_test.py index bfbc0a069..e08f6ce6a 100644 --- a/umu/umu_test.py +++ b/umu/umu_test.py @@ -51,7 +51,6 @@ def setUp(self): "LD_PRELOAD": "", "WINEDLLPATH": "", "WINETRICKS_SUPER_QUIET": "", - "UMU_NO_RUNTIME": "", } self.user = getpwuid(os.getuid()).pw_name self.test_opts = "-foo -bar" @@ -1649,7 +1648,6 @@ def test_set_env(self): os.environ["GAMEID"] = test_str os.environ["STORE"] = test_str os.environ["PROTON_VERB"] = self.test_verb - os.environ["UMU_NO_RUNTIME"] = "pressure-vessel" # Args result = umu_run.parse_args() self.assertIsInstance(result, tuple, "Expected a tuple") @@ -1763,11 +1761,6 @@ def test_set_env(self): self.env["STEAM_COMPAT_TOOL_PATHS"], "Expected STEAM_COMPAT_MOUNTS to be set", ) - self.assertEqual( - self.env["UMU_NO_RUNTIME"], - os.environ["UMU_NO_RUNTIME"], - "Expected UMU_NO_RUNTIME to be set", - ) def test_set_env_winetricks(self): """Test set_env when using winetricks."""