From 1d044bf320cd0c9d03daa8213df078e834e20c49 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Sat, 19 Jul 2025 19:35:30 -0400 Subject: restore script env var val on mount check and UI state set --- py_modules/lsfg_vk/config_schema.py | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'py_modules/lsfg_vk/config_schema.py') diff --git a/py_modules/lsfg_vk/config_schema.py b/py_modules/lsfg_vk/config_schema.py index 54e414f..1098248 100644 --- a/py_modules/lsfg_vk/config_schema.py +++ b/py_modules/lsfg_vk/config_schema.py @@ -315,6 +315,73 @@ class ConfigurationManager: # If parsing fails completely, return defaults return ConfigurationManager.get_defaults() + @staticmethod + def parse_script_content(script_content: str) -> Dict[str, Union[bool, int, str]]: + """Parse launch script content to extract environment variable values + + Args: + script_content: Content of the launch script file + + Returns: + Dict containing parsed script-only field values + """ + script_values = {} + + try: + lines = script_content.split('\n') + + for line in lines: + line = line.strip() + + # Skip comments, empty lines, and non-export lines + if not line or line.startswith('#') or not line.startswith('export '): + continue + + # Parse export statements: export VAR=value + if '=' in line: + # Remove 'export ' prefix + export_line = line[7:] # len('export ') = 7 + key, value = export_line.split('=', 1) + key = key.strip() + value = value.strip() + + # Map environment variables to config field names + if key == "DXVK_FRAME_RATE": + try: + script_values["dxvk_frame_rate"] = int(value) + except ValueError: + pass + elif key == "PROTON_USE_WOW64": + script_values["enable_wow64"] = value == "1" + elif key == "SteamDeck": + script_values["disable_steamdeck_mode"] = value == "0" + + except Exception: + # If parsing fails, return empty dict (will use defaults) + pass + + return script_values + + @staticmethod + def merge_config_with_script(toml_config: ConfigurationData, script_values: Dict[str, Union[bool, int, str]]) -> ConfigurationData: + """Merge TOML configuration with script environment variable values + + Args: + toml_config: Configuration loaded from TOML file + script_values: Environment variable values parsed from script + + Returns: + Complete configuration with script values overlaid on TOML config + """ + merged_config = dict(toml_config) + + # Update script-only fields with values from script + for field_name in SCRIPT_ONLY_FIELDS.keys(): + if field_name in script_values: + merged_config[field_name] = script_values[field_name] + + return cast(ConfigurationData, merged_config) + @staticmethod def create_config_from_args(dll: str, multiplier: int, flow_scale: float, performance_mode: bool, hdr_mode: bool, -- cgit v1.2.3