Skip to content

Commit

Permalink
Merge branch 'Open-Wine-Components:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
beh-10257 authored Oct 22, 2024
2 parents 3fc47eb + 5ea4c99 commit e5b4a75
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def set_env(
if is_createpfx:
env["EXE"] = ""
env["STEAM_COMPAT_INSTALL_PATH"] = ""
env["PROTON_VERB"] = "run"
elif is_winetricks:
# Make an absolute path to winetricks within GE-Proton or UMU-Proton.
# The launcher will change to the winetricks parent directory before
Expand All @@ -236,7 +235,6 @@ def set_env(
env["EXE"] = str(exe)
args = (env["EXE"], args[1]) # type: ignore
env["STEAM_COMPAT_INSTALL_PATH"] = str(exe.parent)
env["PROTON_VERB"] = "run"
elif is_cmd:
try:
# Ensure executable path is absolute, otherwise Proton will fail
Expand Down Expand Up @@ -337,6 +335,7 @@ def build_command(
opts: list[str] = [],
) -> tuple[Path | str, ...]:
"""Build the command to be executed."""
shim: Path = local.joinpath("umu-shim")
proton: Path = Path(env["PROTONPATH"], "proton")
entry_point: Path = local.joinpath("umu")

Expand Down Expand Up @@ -375,6 +374,7 @@ def build_command(
"--verb",
env["PROTON_VERB"],
"--",
shim,
proton,
env["PROTON_VERB"],
env["EXE"],
Expand Down
38 changes: 38 additions & 0 deletions umu/umu_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,34 @@
has_data_filter: bool = False


def create_shim(file_path=None):

Check failure on line 36 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (D103)

umu/umu_runtime.py:36:5: D103 Missing docstring in public function

Check failure on line 36 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (ANN001)

umu/umu_runtime.py:36:17: ANN001 Missing type annotation for function argument `file_path`

Check failure on line 36 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (D103)

umu/umu_runtime.py:36:5: D103 Missing docstring in public function

Check failure on line 36 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (ANN001)

umu/umu_runtime.py:36:17: ANN001 Missing type annotation for function argument `file_path`

Check failure on line 36 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (D103)

umu/umu_runtime.py:36:5: D103 Missing docstring in public function

Check failure on line 36 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (ANN001)

umu/umu_runtime.py:36:17: ANN001 Missing type annotation for function argument `file_path`
# Set the default path if none is provided
if file_path is None:
file_path = UMU_LOCAL.joinpath("umu-shim")
# Define the content of the shell script
script_content = """#!/bin/sh
if [ "${XDG_CURRENT_DESKTOP}" = "gamescope" ] || [ "${XDG_SESSION_DESKTOP}" = "gamescope" ]; then
# Check if STEAM_MULTIPLE_XWAYLANDS is set to 1
if [ "${STEAM_MULTIPLE_XWAYLANDS}" = "1" ]; then
# Check if DISPLAY is set, if not, set it to ":1"
if [ -z "${DISPLAY}" ]; then
export DISPLAY=":1"
fi
fi
fi
# Execute the passed command
"$@"
"""

# Write the script content to the specified file path
with open(file_path, 'w') as file:

Check failure on line 58 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (PTH123)

umu/umu_runtime.py:58:10: PTH123 `open()` should be replaced by `Path.open()`

Check failure on line 58 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (PTH123)

umu/umu_runtime.py:58:10: PTH123 `open()` should be replaced by `Path.open()`

Check failure on line 58 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (PTH123)

umu/umu_runtime.py:58:10: PTH123 `open()` should be replaced by `Path.open()`
file.write(script_content)

# Make the script executable
os.chmod(file_path, 0o755)

Check failure on line 62 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (PTH101)

umu/umu_runtime.py:62:5: PTH101 `os.chmod()` should be replaced by `Path.chmod()`

Check failure on line 62 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (S103)

umu/umu_runtime.py:62:25: S103 `os.chmod` setting a permissive mask `0o755` on file or directory

Check failure on line 62 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (PTH101)

umu/umu_runtime.py:62:5: PTH101 `os.chmod()` should be replaced by `Path.chmod()`

Check failure on line 62 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (S103)

umu/umu_runtime.py:62:25: S103 `os.chmod` setting a permissive mask `0o755` on file or directory

Check failure on line 62 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (PTH101)

umu/umu_runtime.py:62:5: PTH101 `os.chmod()` should be replaced by `Path.chmod()`

Check failure on line 62 in umu/umu_runtime.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (S103)

umu/umu_runtime.py:62:25: S103 `os.chmod` setting a permissive mask `0o755` on file or directory

def _install_umu(
json: dict[str, Any],
thread_pool: ThreadPoolExecutor,
Expand Down Expand Up @@ -177,6 +205,7 @@ def _install_umu(
# Rename _v2-entry-point
log.debug("Renaming: _v2-entry-point -> umu")
UMU_LOCAL.joinpath("_v2-entry-point").rename(UMU_LOCAL.joinpath("umu"))
create_shim()

# Validate the runtime after moving the files
check_runtime(UMU_LOCAL, json)
Expand Down Expand Up @@ -368,6 +397,9 @@ def _update_umu(
rmtree(str(runtime))
log.debug("Released file lock '%s'", lock.lock_file)

if not UMU_LOCAL.joinpath("umu-shim").exists():
create_shim()

log.console("steamrt is up to date")


Expand Down Expand Up @@ -474,6 +506,9 @@ def check_runtime(src: Path, json: dict[str, Any]) -> int:
return ret
log.console(f"{runtime.name}: mtree is OK")

if not UMU_LOCAL.joinpath("umu-shim").exists():
create_shim()

return ret


Expand All @@ -491,3 +526,6 @@ def _restore_umu(
return
_install_umu(json, thread_pool, client_session)
log.debug("Released file lock '%s'", lock.lock_file)

if not UMU_LOCAL.joinpath("umu-shim").exists():
create_shim()

0 comments on commit e5b4a75

Please sign in to comment.