1
0
Fork 0
mirror of synced 2024-06-02 02:34:40 +12:00

Flatpak: Don't export subprocess's env in flatpak's env

This commit is contained in:
loathingKernel 2023-12-06 10:21:40 +02:00
parent 193b5fba44
commit 75a339d390
No known key found for this signature in database
GPG key ID: CE0C72D0B53821FD
2 changed files with 15 additions and 13 deletions

View file

@ -71,19 +71,20 @@ def get_origin_params(core: LegendaryCore, app_name, offline: bool,
command.append(origin_uri)
env = core.get_app_environment(app_name)
launch_args.environment = QProcessEnvironment.systemEnvironment()
if os.environ.get("container") == "flatpak":
flatpak_command = ["flatpak-spawn", "--host"]
for name, value in env.items():
flatpak_command.append(f"--env={name}={value}")
command = flatpak_command + command
launch_args.environment = QProcessEnvironment.systemEnvironment()
for name, value in env.items():
launch_args.environment.insert(name, value)
else:
for name, value in env.items():
launch_args.environment.insert(name, value)
launch_args.executable = command[0]
launch_args.arguments = command[1:]
return launch_args
@ -108,11 +109,15 @@ def get_game_params(core: LegendaryCore, igame: InstalledGame, args: InitArgs,
)
full_params = []
launch_args.environment = QProcessEnvironment.systemEnvironment()
if os.environ.get("container") == "flatpak":
full_params.extend(["flatpak-spawn", "--host"])
for name, value in params.environment.items():
full_params.append(f"--env={name}={value}")
else:
for name, value in params.environment.items():
launch_args.environment.insert(name, value)
full_params.extend(params.launch_command)
full_params.append(
@ -124,11 +129,8 @@ def get_game_params(core: LegendaryCore, igame: InstalledGame, args: InitArgs,
launch_args.executable = full_params[0]
launch_args.arguments = full_params[1:]
launch_args.environment = QProcessEnvironment.systemEnvironment()
for name, value in params.environment.items():
launch_args.environment.insert(name, value)
launch_args.working_directory = params.working_directory
return launch_args

View file

@ -22,15 +22,15 @@ def read_registry(registry: str, wine_pfx: str) -> ConfigParser:
return reg
def execute(cmd: List, wine_env: Mapping) -> Tuple[str, str]:
def execute(command: List, wine_env: Mapping) -> Tuple[str, str]:
if os.environ.get("container") == "flatpak":
flatpak_cmd = ["flatpak-spawn", "--host"]
flatpak_command = ["flatpak-spawn", "--host"]
for name, value in wine_env.items():
flatpak_cmd.append(f"--env={name}={value}")
cmd = flatpak_cmd + cmd
flatpak_command.append(f"--env={name}={value}")
command = flatpak_command + command
try:
proc = subprocess.Popen(
cmd,
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
# Use the current environment if we are in flatpak or our own if we are on host