Skip to content

Commit

Permalink
Support a Steam verb as the first argument
Browse files Browse the repository at this point in the history
To retain Steam's calling convention, check if the first argument is a
known verb. If it is and `PROTON_VERB` is unset, assign it to `PROTON_VERB`
and remove it from the arguments list.

This is a bit hacky but works as PoC
  • Loading branch information
loathingKernel committed Feb 19, 2024
1 parent 33bd828 commit 82b66ad
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions ulwgl_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
import subprocess
from ulwgl_dl_util import get_ulwgl_proton

verbs: Set[str] = {
"waitforexitandrun",
"run",
"runinprefix",
"destroyprefix",
"getcompatpath",
"getnativepath",
}


def parse_args() -> Union[Namespace, Tuple[str, List[str]]]: # noqa: D103
opt_args: Set[str] = {"--help", "-h", "--config"}
Expand Down Expand Up @@ -41,6 +50,11 @@ def parse_args() -> Union[Namespace, Tuple[str, List[str]]]: # noqa: D103
if sys.argv[1:][0] in opt_args:
return parser.parse_args(sys.argv[1:])

if sys.argv[1] in verbs:
if "PROTON_VERB" not in os.environ:
os.environ["PROTON_VERB"] = sys.argv[1]
sys.argv.pop(1)

return sys.argv[1], sys.argv[2:]


Expand Down Expand Up @@ -120,15 +134,13 @@ def check_env(
os.environ["PROTONPATH"] = ""
get_ulwgl_proton(env)
elif Path("~/.local/share/Steam/compatibilitytools.d/" + os.environ["PROTONPATH"]).expanduser().is_dir():
env["PROTONPATH"] = Path("~/.local/share/Steam/compatibilitytools.d/").expanduser().joinpath(os.environ["PROTONPATH"])
env["PROTONPATH"] = Path("~/.local/share/Steam/compatibilitytools.d/").expanduser().joinpath(os.environ["PROTONPATH"]).as_posix()
elif not Path(os.environ["PROTONPATH"]).expanduser().is_dir():
os.environ["PROTONPATH"] = ""
get_ulwgl_proton(env)
else:
env["PROTONPATH"] = os.environ["PROTONPATH"]

print(env["PROTONPATH"])

# If download fails/doesn't exist in the system, raise an error
if not os.environ["PROTONPATH"]:
err: str = "Download failed.\nProton could not be found in cache or compatibilitytools.d\nPlease set $PROTONPATH or visit https://github.com/Open-Wine-Components/ULWGL-Proton/releases"
Expand All @@ -144,15 +156,6 @@ def set_env(
Filesystem paths will be formatted and expanded as POSIX
"""
verbs: Set[str] = {
"waitforexitandrun",
"run",
"runinprefix",
"destroyprefix",
"getcompatpath",
"getnativepath",
}

# PROTON_VERB
# For invalid Proton verbs, just assign the waitforexitandrun
if "PROTON_VERB" in os.environ and os.environ["PROTON_VERB"] in verbs:
Expand Down

0 comments on commit 82b66ad

Please sign in to comment.