protontool: support steam %command% syntax

master
Taeyeon Mori 3 years ago
parent 29d095cccc
commit 767516f0fb
  1. 20
      bin/protontool

@ -7,6 +7,7 @@
import steamutil import steamutil
import argparse import argparse
import sys, os import sys, os
import shlex
from pathlib import Path from pathlib import Path
@ -59,6 +60,11 @@ class ProcessLaunchInfo:
f.flush() f.flush()
if self.workingdir is not None: if self.workingdir is not None:
os.chdir(self.workingdir) os.chdir(self.workingdir)
# Grab environment vars from cmdline
while "=" in self.argv[0]:
k, v = self.argv[0].split('=', 1)
self.environ[k]=v
self.argv.pop(0)
os.execve(self.argv[0], self.argv, self.environ) os.execve(self.argv[0], self.argv, self.environ)
@ -393,16 +399,22 @@ class ProtonTool:
print_error("No launch config for %s in appinfo for %s" % (target_oslist, self.app.name)) print_error("No launch config for %s in appinfo for %s" % (target_oslist, self.app.name))
return 51 return 51
if tool is not None:
self.tool_apply(proc, tool, "waitforexitandrun" if self.args.waitforexit else "run")
if not self.args.no_args: if not self.args.no_args:
if "args" in self.args and self.args.args: if "args" in self.args and self.args.args:
proc.argv.extend(self.args.args) proc.argv.extend(self.args.args)
else: else:
uc = self.user.get_app_config(self.app) uc = self.user.get_app_config(self.app)
if uc and uc.launch_options: if uc and uc.launch_options:
proc.argv.extend(uc.launch_options.split()) add_args = shlex.split(uc.launch_options)
try:
if tool is not None: cmd_i = add_args.index(r"%command%")
self.tool_apply(proc, tool, "waitforexitandrun" if self.args.waitforexit else "run") except ValueError:
proc.argv.extend(add_args)
else:
proc.argv = [*add_args[:cmd_i], *proc.argv, *add_args[cmd_i+1:]]
proc.exec() proc.exec()

Loading…
Cancel
Save