Skip to content

Commit

Permalink
fix: remove leading spaces in shim (#275)
Browse files Browse the repository at this point in the history
* umu_runtime: fix format of shim file

- Using a docstring resulted in each line having a leading space character. Instead, prefer to create individual strings and concat them

* umu_runtime: add new line in shim
  • Loading branch information
R1kaB3rN authored Nov 14, 2024
1 parent aaf2b26 commit 66a1088
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions umu/umu_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,29 @@ def create_shim(file_path: Path | None = None):
# 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
"$@"
# Capture the exit status
status=$?
echo "Command exited with status: $status" >&2
exit $status
"""
script_content = (
"#!/bin/sh\n"
"\n"
'if [ "${XDG_CURRENT_DESKTOP}" = "gamescope" ] || [ "${XDG_SESSION_DESKTOP}" = "gamescope" ]; then\n'
" # Check if STEAM_MULTIPLE_XWAYLANDS is set to 1\n"
' if [ "${STEAM_MULTIPLE_XWAYLANDS}" = "1" ]; then\n'
' # Check if DISPLAY is set, if not, set it to ":1"\n'
' if [ -z "${DISPLAY}" ]; then\n'
' export DISPLAY=":1"\n'
" fi\n"
" fi\n"
"fi\n"
"\n"
"# Execute the passed command\n"
'"$@"\n'
"\n"
"# Capture the exit status\n"
"status=$?\n"
'echo "Command exited with status: $status" >&2\n'
"exit $status\n"
)

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

0 comments on commit 66a1088

Please sign in to comment.