We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Lutris shell script generation leaves out overrides based on DLL selection for the runner
### Bug description

Executing `lutris -b /some/path.sh lutris:write-script/<some game>` generates environment variables and templates them into a shell script that is supposed to be suitable for starting the game. Because of the order that the environment is built in this method, the runner doesn't undergo its `prelaunch` and properly populate environment variables, so `get_launch_parameters` doesn't return the proper WINEDLLOVERRIDES and the generated script is incomplete, not taking advantage of DXVK and other important DLLs that should be used.

### How to Reproduce

Steps to reproduce the behavior:
1. Install a game
2. Configure DXVK or some other runner option that's enabled via WINEDLLOVERRIDE
3. At a terminal run `lutris -b /tmp/game.sh lutris:write-script/1` or swap the `1` for the game ID of the game you installed.
4. `grep WINEDLLOVERRIDES /tmp/game.sh` and note the lack of overrides for the things configured in step 2


### Expected behavior

I expect the generated script to be able to adequately launch the game without Lutris, using the options I'd configured in Lutris. For example, when launching a copy of the same game from lutris, I see the following:

```
$ xargs -0 -n 1 echo < /proc/396196/environ | grep WINEDLLOVERRIDES
WINEDLLOVERRIDES=d3d10core,d3d11,d3d12,d3d9,d3dcompiler_42,d3dcompiler_43,d3dcompiler_46,d3dcompiler_47,d3dx10,d3dx10_33,d3dx10_34,d3dx10_35,d3dx10_36,d3dx10_37,d3dx10_38,d3dx10_39,d3dx10_40,d3dx10_41,d3dx10_42,d3dx10_43,d3dx11_42,d3dx11_43,d3dx9_24,d3dx9_25,d3dx9_26,d3dx9_27,d3dx9_28,d3dx9_29,d3dx9_30,d3dx9_31,d3dx9_32,d3dx9_33,d3dx9_34,d3dx9_35,d3dx9_36,d3dx9_37,d3dx9_38,d3dx9_39,d3dx9_40,d3dx9_41,d3dx9_42,d3dx9_43,dxgi=n;winemenubuilder=
```

### Log output

```shell
$ lutris -b /tmp/gw2.sh lutris:write-script/1
2022-01-30 13:42:52,767: Magic not available. Unable to automatically find game executables. Please install python-magic
2022-01-30 13:42:52,792: Starting Lutris 0.5.9.1
2022-01-30 13:42:52,806: No cores found
2022-01-30 13:42:53,813: Failed to read content length on response from https://api.github.com/repos/lutris/dxvk-nvapi/releases
2022-01-30 13:42:54,141: Startup complete
2022-01-30 13:42:54,142: Running AMD Mesa driver 21.3.4 on AMD Radeon RX 5700 XT (NAVI10, DRM 3.42.0, 5.15.16-200.fc35.x86_64, LLVM 13.0.0) (0x731f)
2022-01-30 13:42:54,142: GPU: 1002:731F 1DA2:E410 (amdgpu drivers)
2022-01-30 13:42:54,212: Shutting down Lutris
$ grep WINEDLLOVERRIDES /tmp/gw2.sh
export WINEDLLOVERRIDES="winemenubuilder="
```
```


### System Information

```shell
[System]
OS:              Fedora Linux 35 
Arch:            x86_64
Kernel:          5.15.16-200.fc35.x86_64
Desktop:         Not found
Display Server:  wayland

[CPU]
Vendor:          AuthenticAMD
Model:           AMD Ryzen 9 5950X 16-Core Processor
Physical cores:  16
Logical cores:   32

[Memory]
RAM:             62.8 GB
Swap:            8.0 GB

[Graphics]
Vendor:          AMD
OpenGL Renderer: AMD Radeon RX 5700 XT (NAVI10, DRM 3.42.0, 5.15.16-200.fc35.x86_64, LLVM 13.0.0)
OpenGL Version:  4.6 (Compatibility Profile) Mesa 21.3.4
OpenGL Core:     4.6 (Core Profile) Mesa 21.3.4
OpenGL ES:       OpenGL ES 3.2 Mesa 21.3.4
Vulkan:          Supported
```


### Media (optional)

_No response_

### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lutris/runner_interpreter.py`
Content:
```
1 """Transform runner parameters to data usable for runtime execution"""
2 import os
3 import shlex
4 import stat
5 
6 from lutris.util import system
7 from lutris.util.linux import LINUX_SYSTEM
8 from lutris.util.log import logger
9 
10 
11 def get_mangohud_conf(system_config):
12     """Return correct launch arguments and environment variables for Mangohud."""
13     env = {"MANGOHUD": "1"}
14     mango_args = []
15     mangohud = system_config.get("mangohud") or ""
16     if mangohud and system.find_executable("mangohud"):
17         if mangohud == "gl64":
18             mango_args = ["mangohud"]
19             env["MANGOHUD_DLSYM"] = "1"
20         elif mangohud == "gl32":
21             mango_args = ["mangohud.x86"]
22             env["MANGOHUD_DLSYM"] = "1"
23         else:
24             mango_args = ["mangohud"]
25     return mango_args, env
26 
27 
28 def get_launch_parameters(runner, gameplay_info):
29     system_config = runner.system_config
30     launch_arguments = gameplay_info["command"]
31     env = {
32         "DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1": "1"
33     }
34 
35     # Steam compatibility
36     if os.environ.get("SteamAppId"):
37         logger.info("Game launched from steam (AppId: %s)", os.environ["SteamAppId"])
38         env["LC_ALL"] = ""
39 
40     # Optimus
41     optimus = system_config.get("optimus")
42     if optimus == "primusrun" and system.find_executable("primusrun"):
43         launch_arguments.insert(0, "primusrun")
44     elif optimus == "optirun" and system.find_executable("optirun"):
45         launch_arguments.insert(0, "virtualgl")
46         launch_arguments.insert(0, "-b")
47         launch_arguments.insert(0, "optirun")
48     elif optimus == "pvkrun" and system.find_executable("pvkrun"):
49         launch_arguments.insert(0, "pvkrun")
50 
51     mango_args, mango_env = get_mangohud_conf(system_config)
52     if mango_args:
53         launch_arguments = mango_args + launch_arguments
54         env.update(mango_env)
55 
56     # Libstrangle
57     fps_limit = system_config.get("fps_limit") or ""
58     if fps_limit:
59         strangle_cmd = system.find_executable("strangle")
60         if strangle_cmd:
61             launch_arguments = [strangle_cmd, fps_limit] + launch_arguments
62         else:
63             logger.warning("libstrangle is not available on this system, FPS limiter disabled")
64 
65     prefix_command = system_config.get("prefix_command") or ""
66     if prefix_command:
67         launch_arguments = (shlex.split(os.path.expandvars(prefix_command)) + launch_arguments)
68 
69     single_cpu = system_config.get("single_cpu") or False
70     if single_cpu:
71         logger.info("The game will run on a single CPU core")
72         launch_arguments.insert(0, "0")
73         launch_arguments.insert(0, "-c")
74         launch_arguments.insert(0, "taskset")
75 
76     env.update(runner.get_env())
77 
78     env.update(gameplay_info.get("env") or {})
79 
80     # Set environment variables dependent on gameplay info
81 
82     # LD_PRELOAD
83     ld_preload = gameplay_info.get("ld_preload")
84     if ld_preload:
85         env["LD_PRELOAD"] = ld_preload
86 
87     # LD_LIBRARY_PATH
88     game_ld_libary_path = gameplay_info.get("ld_library_path")
89     if game_ld_libary_path:
90         ld_library_path = env.get("LD_LIBRARY_PATH")
91         if not ld_library_path:
92             ld_library_path = "$LD_LIBRARY_PATH"
93         env["LD_LIBRARY_PATH"] = ":".join([game_ld_libary_path, ld_library_path])
94 
95     # Feral gamemode
96     gamemode = system_config.get("gamemode") and LINUX_SYSTEM.gamemode_available()
97     if gamemode:
98         launch_arguments.insert(0, "gamemoderun")
99 
100     # Gamescope
101     gamescope = system_config.get("gamescope") and system.find_executable("gamescope")
102     if gamescope:
103         launch_arguments = get_gamescope_args(launch_arguments, system_config)
104 
105     return launch_arguments, env
106 
107 
108 def get_gamescope_args(launch_arguments, system_config):
109     """Insert gamescope at the start of the launch arguments"""
110     launch_arguments.insert(0, "--")
111     launch_arguments.insert(0, "-f")
112     if system_config.get("gamescope_output_res"):
113         output_width, output_height = system_config["gamescope_output_res"].lower().split("x")
114         launch_arguments.insert(0, output_height)
115         launch_arguments.insert(0, "-H")
116         launch_arguments.insert(0, output_width)
117         launch_arguments.insert(0, "-W")
118     if system_config.get("gamescope_game_res"):
119         game_width, game_height = system_config["gamescope_game_res"].lower().split("x")
120         launch_arguments.insert(0, game_height)
121         launch_arguments.insert(0, "-h")
122         launch_arguments.insert(0, game_width)
123         launch_arguments.insert(0, "-w")
124     launch_arguments.insert(0, "gamescope")
125     return launch_arguments
126 
127 
128 def export_bash_script(runner, gameplay_info, script_path):
129     """Convert runner configuration into a bash script"""
130     command, env = get_launch_parameters(runner, gameplay_info)
131     # Override TERM otherwise the script might not run
132     env["TERM"] = "xterm"
133     script_content = "#!/bin/bash\n\n\n"
134     script_content += "# Environment variables\n"
135     for name, value in env.items():
136         script_content += 'export %s="%s"\n' % (name, value)
137     script_content += "\n# Command\n"
138     script_content += " ".join([shlex.quote(c) for c in command])
139     with open(script_path, "w", encoding='utf-8') as script_file:
140         script_file.write(script_content)
141 
142     os.chmod(script_path, os.stat(script_path).st_mode | stat.S_IEXEC)
143
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lutris/runner_interpreter.py b/lutris/runner_interpreter.py
--- a/lutris/runner_interpreter.py
+++ b/lutris/runner_interpreter.py
@@ -127,6 +127,8 @@
 
 def export_bash_script(runner, gameplay_info, script_path):
     """Convert runner configuration into a bash script"""
+    if getattr(runner, 'prelaunch', None) is not None:
+        runner.prelaunch()
     command, env = get_launch_parameters(runner, gameplay_info)
     # Override TERM otherwise the script might not run
     env["TERM"] = "xterm"

{"golden_diff": "diff --git a/lutris/runner_interpreter.py b/lutris/runner_interpreter.py\n--- a/lutris/runner_interpreter.py\n+++ b/lutris/runner_interpreter.py\n@@ -127,6 +127,8 @@\n \n def export_bash_script(runner, gameplay_info, script_path):\n     \"\"\"Convert runner configuration into a bash script\"\"\"\n+    if getattr(runner, 'prelaunch', None) is not None:\n+        runner.prelaunch()\n     command, env = get_launch_parameters(runner, gameplay_info)\n     # Override TERM otherwise the script might not run\n     env[\"TERM\"] = \"xterm\"\n", "issue": "Lutris shell script generation leaves out overrides based on DLL selection for the runner\n### Bug description\n\nExecuting `lutris -b /some/path.sh lutris:write-script/<some game>` generates environment variables and templates them into a shell script that is supposed to be suitable for starting the game. Because of the order that the environment is built in this method, the runner doesn't undergo its `prelaunch` and properly populate environment variables, so `get_launch_parameters` doesn't return the proper WINEDLLOVERRIDES and the generated script is incomplete, not taking advantage of DXVK and other important DLLs that should be used.\n\n### How to Reproduce\n\nSteps to reproduce the behavior:\r\n1. Install a game\r\n2. Configure DXVK or some other runner option that's enabled via WINEDLLOVERRIDE\r\n3. At a terminal run `lutris -b /tmp/game.sh lutris:write-script/1` or swap the `1` for the game ID of the game you installed.\r\n4. `grep WINEDLLOVERRIDES /tmp/game.sh` and note the lack of overrides for the things configured in step 2\r\n\n\n### Expected behavior\n\nI expect the generated script to be able to adequately launch the game without Lutris, using the options I'd configured in Lutris. For example, when launching a copy of the same game from lutris, I see the following:\r\n\r\n```\r\n$ xargs -0 -n 1 echo < /proc/396196/environ | grep WINEDLLOVERRIDES\r\nWINEDLLOVERRIDES=d3d10core,d3d11,d3d12,d3d9,d3dcompiler_42,d3dcompiler_43,d3dcompiler_46,d3dcompiler_47,d3dx10,d3dx10_33,d3dx10_34,d3dx10_35,d3dx10_36,d3dx10_37,d3dx10_38,d3dx10_39,d3dx10_40,d3dx10_41,d3dx10_42,d3dx10_43,d3dx11_42,d3dx11_43,d3dx9_24,d3dx9_25,d3dx9_26,d3dx9_27,d3dx9_28,d3dx9_29,d3dx9_30,d3dx9_31,d3dx9_32,d3dx9_33,d3dx9_34,d3dx9_35,d3dx9_36,d3dx9_37,d3dx9_38,d3dx9_39,d3dx9_40,d3dx9_41,d3dx9_42,d3dx9_43,dxgi=n;winemenubuilder=\r\n```\n\n### Log output\n\n```shell\n$ lutris -b /tmp/gw2.sh lutris:write-script/1\r\n2022-01-30 13:42:52,767: Magic not available. Unable to automatically find game executables. Please install python-magic\r\n2022-01-30 13:42:52,792: Starting Lutris 0.5.9.1\r\n2022-01-30 13:42:52,806: No cores found\r\n2022-01-30 13:42:53,813: Failed to read content length on response from https://api.github.com/repos/lutris/dxvk-nvapi/releases\r\n2022-01-30 13:42:54,141: Startup complete\r\n2022-01-30 13:42:54,142: Running AMD Mesa driver 21.3.4 on AMD Radeon RX 5700 XT (NAVI10, DRM 3.42.0, 5.15.16-200.fc35.x86_64, LLVM 13.0.0) (0x731f)\r\n2022-01-30 13:42:54,142: GPU: 1002:731F 1DA2:E410 (amdgpu drivers)\r\n2022-01-30 13:42:54,212: Shutting down Lutris\r\n$ grep WINEDLLOVERRIDES /tmp/gw2.sh\r\nexport WINEDLLOVERRIDES=\"winemenubuilder=\"\r\n```\n```\n\n\n### System Information\n\n```shell\n[System]\r\nOS:              Fedora Linux 35 \r\nArch:            x86_64\r\nKernel:          5.15.16-200.fc35.x86_64\r\nDesktop:         Not found\r\nDisplay Server:  wayland\r\n\r\n[CPU]\r\nVendor:          AuthenticAMD\r\nModel:           AMD Ryzen 9 5950X 16-Core Processor\r\nPhysical cores:  16\r\nLogical cores:   32\r\n\r\n[Memory]\r\nRAM:             62.8 GB\r\nSwap:            8.0 GB\r\n\r\n[Graphics]\r\nVendor:          AMD\r\nOpenGL Renderer: AMD Radeon RX 5700 XT (NAVI10, DRM 3.42.0, 5.15.16-200.fc35.x86_64, LLVM 13.0.0)\r\nOpenGL Version:  4.6 (Compatibility Profile) Mesa 21.3.4\r\nOpenGL Core:     4.6 (Core Profile) Mesa 21.3.4\r\nOpenGL ES:       OpenGL ES 3.2 Mesa 21.3.4\r\nVulkan:          Supported\n```\n\n\n### Media (optional)\n\n_No response_\n\n### Checklist:\n\n- [X] I'm not asking for support with a game or the wine runner.\n- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.\n- [X] I have checked for existing issues that describe my problem prior to opening this one.\n- [X] I understand that improperly formatted bug reports may be closed without explanation.\n", "before_files": [{"content": "\"\"\"Transform runner parameters to data usable for runtime execution\"\"\"\nimport os\nimport shlex\nimport stat\n\nfrom lutris.util import system\nfrom lutris.util.linux import LINUX_SYSTEM\nfrom lutris.util.log import logger\n\n\ndef get_mangohud_conf(system_config):\n    \"\"\"Return correct launch arguments and environment variables for Mangohud.\"\"\"\n    env = {\"MANGOHUD\": \"1\"}\n    mango_args = []\n    mangohud = system_config.get(\"mangohud\") or \"\"\n    if mangohud and system.find_executable(\"mangohud\"):\n        if mangohud == \"gl64\":\n            mango_args = [\"mangohud\"]\n            env[\"MANGOHUD_DLSYM\"] = \"1\"\n        elif mangohud == \"gl32\":\n            mango_args = [\"mangohud.x86\"]\n            env[\"MANGOHUD_DLSYM\"] = \"1\"\n        else:\n            mango_args = [\"mangohud\"]\n    return mango_args, env\n\n\ndef get_launch_parameters(runner, gameplay_info):\n    system_config = runner.system_config\n    launch_arguments = gameplay_info[\"command\"]\n    env = {\n        \"DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1\": \"1\"\n    }\n\n    # Steam compatibility\n    if os.environ.get(\"SteamAppId\"):\n        logger.info(\"Game launched from steam (AppId: %s)\", os.environ[\"SteamAppId\"])\n        env[\"LC_ALL\"] = \"\"\n\n    # Optimus\n    optimus = system_config.get(\"optimus\")\n    if optimus == \"primusrun\" and system.find_executable(\"primusrun\"):\n        launch_arguments.insert(0, \"primusrun\")\n    elif optimus == \"optirun\" and system.find_executable(\"optirun\"):\n        launch_arguments.insert(0, \"virtualgl\")\n        launch_arguments.insert(0, \"-b\")\n        launch_arguments.insert(0, \"optirun\")\n    elif optimus == \"pvkrun\" and system.find_executable(\"pvkrun\"):\n        launch_arguments.insert(0, \"pvkrun\")\n\n    mango_args, mango_env = get_mangohud_conf(system_config)\n    if mango_args:\n        launch_arguments = mango_args + launch_arguments\n        env.update(mango_env)\n\n    # Libstrangle\n    fps_limit = system_config.get(\"fps_limit\") or \"\"\n    if fps_limit:\n        strangle_cmd = system.find_executable(\"strangle\")\n        if strangle_cmd:\n            launch_arguments = [strangle_cmd, fps_limit] + launch_arguments\n        else:\n            logger.warning(\"libstrangle is not available on this system, FPS limiter disabled\")\n\n    prefix_command = system_config.get(\"prefix_command\") or \"\"\n    if prefix_command:\n        launch_arguments = (shlex.split(os.path.expandvars(prefix_command)) + launch_arguments)\n\n    single_cpu = system_config.get(\"single_cpu\") or False\n    if single_cpu:\n        logger.info(\"The game will run on a single CPU core\")\n        launch_arguments.insert(0, \"0\")\n        launch_arguments.insert(0, \"-c\")\n        launch_arguments.insert(0, \"taskset\")\n\n    env.update(runner.get_env())\n\n    env.update(gameplay_info.get(\"env\") or {})\n\n    # Set environment variables dependent on gameplay info\n\n    # LD_PRELOAD\n    ld_preload = gameplay_info.get(\"ld_preload\")\n    if ld_preload:\n        env[\"LD_PRELOAD\"] = ld_preload\n\n    # LD_LIBRARY_PATH\n    game_ld_libary_path = gameplay_info.get(\"ld_library_path\")\n    if game_ld_libary_path:\n        ld_library_path = env.get(\"LD_LIBRARY_PATH\")\n        if not ld_library_path:\n            ld_library_path = \"$LD_LIBRARY_PATH\"\n        env[\"LD_LIBRARY_PATH\"] = \":\".join([game_ld_libary_path, ld_library_path])\n\n    # Feral gamemode\n    gamemode = system_config.get(\"gamemode\") and LINUX_SYSTEM.gamemode_available()\n    if gamemode:\n        launch_arguments.insert(0, \"gamemoderun\")\n\n    # Gamescope\n    gamescope = system_config.get(\"gamescope\") and system.find_executable(\"gamescope\")\n    if gamescope:\n        launch_arguments = get_gamescope_args(launch_arguments, system_config)\n\n    return launch_arguments, env\n\n\ndef get_gamescope_args(launch_arguments, system_config):\n    \"\"\"Insert gamescope at the start of the launch arguments\"\"\"\n    launch_arguments.insert(0, \"--\")\n    launch_arguments.insert(0, \"-f\")\n    if system_config.get(\"gamescope_output_res\"):\n        output_width, output_height = system_config[\"gamescope_output_res\"].lower().split(\"x\")\n        launch_arguments.insert(0, output_height)\n        launch_arguments.insert(0, \"-H\")\n        launch_arguments.insert(0, output_width)\n        launch_arguments.insert(0, \"-W\")\n    if system_config.get(\"gamescope_game_res\"):\n        game_width, game_height = system_config[\"gamescope_game_res\"].lower().split(\"x\")\n        launch_arguments.insert(0, game_height)\n        launch_arguments.insert(0, \"-h\")\n        launch_arguments.insert(0, game_width)\n        launch_arguments.insert(0, \"-w\")\n    launch_arguments.insert(0, \"gamescope\")\n    return launch_arguments\n\n\ndef export_bash_script(runner, gameplay_info, script_path):\n    \"\"\"Convert runner configuration into a bash script\"\"\"\n    command, env = get_launch_parameters(runner, gameplay_info)\n    # Override TERM otherwise the script might not run\n    env[\"TERM\"] = \"xterm\"\n    script_content = \"#!/bin/bash\\n\\n\\n\"\n    script_content += \"# Environment variables\\n\"\n    for name, value in env.items():\n        script_content += 'export %s=\"%s\"\\n' % (name, value)\n    script_content += \"\\n# Command\\n\"\n    script_content += \" \".join([shlex.quote(c) for c in command])\n    with open(script_path, \"w\", encoding='utf-8') as script_file:\n        script_file.write(script_content)\n\n    os.chmod(script_path, os.stat(script_path).st_mode | stat.S_IEXEC)\n", "path": "lutris/runner_interpreter.py"}], "after_files": [{"content": "\"\"\"Transform runner parameters to data usable for runtime execution\"\"\"\nimport os\nimport shlex\nimport stat\n\nfrom lutris.util import system\nfrom lutris.util.linux import LINUX_SYSTEM\nfrom lutris.util.log import logger\n\n\ndef get_mangohud_conf(system_config):\n    \"\"\"Return correct launch arguments and environment variables for Mangohud.\"\"\"\n    env = {\"MANGOHUD\": \"1\"}\n    mango_args = []\n    mangohud = system_config.get(\"mangohud\") or \"\"\n    if mangohud and system.find_executable(\"mangohud\"):\n        if mangohud == \"gl64\":\n            mango_args = [\"mangohud\"]\n            env[\"MANGOHUD_DLSYM\"] = \"1\"\n        elif mangohud == \"gl32\":\n            mango_args = [\"mangohud.x86\"]\n            env[\"MANGOHUD_DLSYM\"] = \"1\"\n        else:\n            mango_args = [\"mangohud\"]\n    return mango_args, env\n\n\ndef get_launch_parameters(runner, gameplay_info):\n    system_config = runner.system_config\n    launch_arguments = gameplay_info[\"command\"]\n    env = {\n        \"DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1\": \"1\"\n    }\n\n    # Steam compatibility\n    if os.environ.get(\"SteamAppId\"):\n        logger.info(\"Game launched from steam (AppId: %s)\", os.environ[\"SteamAppId\"])\n        env[\"LC_ALL\"] = \"\"\n\n    # Optimus\n    optimus = system_config.get(\"optimus\")\n    if optimus == \"primusrun\" and system.find_executable(\"primusrun\"):\n        launch_arguments.insert(0, \"primusrun\")\n    elif optimus == \"optirun\" and system.find_executable(\"optirun\"):\n        launch_arguments.insert(0, \"virtualgl\")\n        launch_arguments.insert(0, \"-b\")\n        launch_arguments.insert(0, \"optirun\")\n    elif optimus == \"pvkrun\" and system.find_executable(\"pvkrun\"):\n        launch_arguments.insert(0, \"pvkrun\")\n\n    mango_args, mango_env = get_mangohud_conf(system_config)\n    if mango_args:\n        launch_arguments = mango_args + launch_arguments\n        env.update(mango_env)\n\n    # Libstrangle\n    fps_limit = system_config.get(\"fps_limit\") or \"\"\n    if fps_limit:\n        strangle_cmd = system.find_executable(\"strangle\")\n        if strangle_cmd:\n            launch_arguments = [strangle_cmd, fps_limit] + launch_arguments\n        else:\n            logger.warning(\"libstrangle is not available on this system, FPS limiter disabled\")\n\n    prefix_command = system_config.get(\"prefix_command\") or \"\"\n    if prefix_command:\n        launch_arguments = (shlex.split(os.path.expandvars(prefix_command)) + launch_arguments)\n\n    single_cpu = system_config.get(\"single_cpu\") or False\n    if single_cpu:\n        logger.info(\"The game will run on a single CPU core\")\n        launch_arguments.insert(0, \"0\")\n        launch_arguments.insert(0, \"-c\")\n        launch_arguments.insert(0, \"taskset\")\n\n    env.update(runner.get_env())\n\n    env.update(gameplay_info.get(\"env\") or {})\n\n    # Set environment variables dependent on gameplay info\n\n    # LD_PRELOAD\n    ld_preload = gameplay_info.get(\"ld_preload\")\n    if ld_preload:\n        env[\"LD_PRELOAD\"] = ld_preload\n\n    # LD_LIBRARY_PATH\n    game_ld_libary_path = gameplay_info.get(\"ld_library_path\")\n    if game_ld_libary_path:\n        ld_library_path = env.get(\"LD_LIBRARY_PATH\")\n        if not ld_library_path:\n            ld_library_path = \"$LD_LIBRARY_PATH\"\n        env[\"LD_LIBRARY_PATH\"] = \":\".join([game_ld_libary_path, ld_library_path])\n\n    # Feral gamemode\n    gamemode = system_config.get(\"gamemode\") and LINUX_SYSTEM.gamemode_available()\n    if gamemode:\n        launch_arguments.insert(0, \"gamemoderun\")\n\n    # Gamescope\n    gamescope = system_config.get(\"gamescope\") and system.find_executable(\"gamescope\")\n    if gamescope:\n        launch_arguments = get_gamescope_args(launch_arguments, system_config)\n\n    return launch_arguments, env\n\n\ndef get_gamescope_args(launch_arguments, system_config):\n    \"\"\"Insert gamescope at the start of the launch arguments\"\"\"\n    launch_arguments.insert(0, \"--\")\n    launch_arguments.insert(0, \"-f\")\n    if system_config.get(\"gamescope_output_res\"):\n        output_width, output_height = system_config[\"gamescope_output_res\"].lower().split(\"x\")\n        launch_arguments.insert(0, output_height)\n        launch_arguments.insert(0, \"-H\")\n        launch_arguments.insert(0, output_width)\n        launch_arguments.insert(0, \"-W\")\n    if system_config.get(\"gamescope_game_res\"):\n        game_width, game_height = system_config[\"gamescope_game_res\"].lower().split(\"x\")\n        launch_arguments.insert(0, game_height)\n        launch_arguments.insert(0, \"-h\")\n        launch_arguments.insert(0, game_width)\n        launch_arguments.insert(0, \"-w\")\n    launch_arguments.insert(0, \"gamescope\")\n    return launch_arguments\n\n\ndef export_bash_script(runner, gameplay_info, script_path):\n    \"\"\"Convert runner configuration into a bash script\"\"\"\n    if getattr(runner, 'prelaunch', None) is not None:\n        runner.prelaunch()\n    command, env = get_launch_parameters(runner, gameplay_info)\n    # Override TERM otherwise the script might not run\n    env[\"TERM\"] = \"xterm\"\n    script_content = \"#!/bin/bash\\n\\n\\n\"\n    script_content += \"# Environment variables\\n\"\n    for name, value in env.items():\n        script_content += 'export %s=\"%s\"\\n' % (name, value)\n    script_content += \"\\n# Command\\n\"\n    script_content += \" \".join([shlex.quote(c) for c in command])\n    with open(script_path, \"w\", encoding='utf-8') as script_file:\n        script_file.write(script_content)\n\n    os.chmod(script_path, os.stat(script_path).st_mode | stat.S_IEXEC)\n", "path": "lutris/runner_interpreter.py"}]}