1
1
"""Starts the protonfix module and runs fixes after pre-flight-checks"""
2
2
3
3
import os
4
+ import subprocess
4
5
import sys
5
6
import traceback
6
7
from typing import Callable
18
19
x86_64_lib_dir : str = f'{ os .path .dirname (os .path .realpath (__file__ ))} /files/lib/x86_64-linux-gnu'
19
20
20
21
22
+ # This is needed for protonfixes
23
+ os .environ ['PROTON_DLL_COPY' ] = '*'
24
+
25
+
21
26
def check_conditions () -> bool :
22
27
"""Determine, if the actual game was executed and protonfixes isn't deactivated.
23
28
@@ -49,6 +54,43 @@ def setup(env: dict, bin_path_var: str, lib_path_var: str, func: Callable[[dict,
49
54
func (env , lib_path_var , f'{ x86_64_lib_dir } :{ i386_lib_dir } ' , ':' )
50
55
51
56
57
+ def winetricks (env : dict , wine_bin , wineserver_bin ) -> None :
58
+ if (env .get ("UMU_ID" )
59
+ and env .get ("EXE" , "" ).endswith ("winetricks" )
60
+ and env .get ("PROTON_VERB" ) == "waitforexitandrun"
61
+ ):
62
+ wt_verbs = " " .join (sys .argv [2 :][2 :])
63
+ env ["WINE" ] = wine_bin
64
+ env ["WINELOADER" ] = wine_bin
65
+ env ["WINESERVER" ] = wineserver_bin
66
+ env ["WINETRICKS_LATEST_VERSION_CHECK" ] = "disabled"
67
+ env ["LD_PRELOAD" ] = ""
68
+
69
+ log (f"Running winetricks verbs in prefix: { wt_verbs } " )
70
+ rc = subprocess .run (sys .argv [2 :], check = False , env = env ).returncode
71
+
72
+ sys .exit (rc )
73
+
74
+
75
+ def _is_directory_empty (dir_path ):
76
+ # Check if the directory is empty
77
+ return not any (os .scandir (dir_path ))
78
+
79
+
80
+ def setup_mount_drives (func : Callable [[str , str , str ], None ]):
81
+ if os .environ .get ('UMU_ID' , '' ):
82
+ drive_map = {
83
+ '/media' : 'u:' ,
84
+ '/run/media' : 'v:' ,
85
+ '/mnt' : 'w:' ,
86
+ os .path .expanduser ('~' ): 'x:' , # Current user's home directory
87
+ }
88
+
89
+ for directory in drive_map .keys ():
90
+ if os .path .exists (directory ) and not _is_directory_empty (directory ):
91
+ func ('gamedrive' , drive_map [directory ], directory )
92
+
93
+
52
94
def execute () -> None :
53
95
"""Execute protonfixes"""
54
96
if check_iscriptevaluator ():
@@ -65,4 +107,4 @@ def execute() -> None:
65
107
sys .stderr .flush ()
66
108
67
109
68
- __all__ = ["setup" , "execute" ]
110
+ __all__ = ["setup" , "execute" , "winetricks" , "setup_mount_drives" ]
0 commit comments