diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-19 19:35:30 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-19 19:35:30 -0400 |
| commit | 1d044bf320cd0c9d03daa8213df078e834e20c49 (patch) | |
| tree | e48cb29f1d32942c04b1d40b7ddcc7cb79d24845 /py_modules/lsfg_vk/config_schema.py | |
| parent | 3ce6ba534900e68c815b4012a456842d3003c6da (diff) | |
| download | decky-lsfg-vk-1d044bf320cd0c9d03daa8213df078e834e20c49.tar.gz decky-lsfg-vk-1d044bf320cd0c9d03daa8213df078e834e20c49.zip | |
restore script env var val on mount check and UI state set
Diffstat (limited to 'py_modules/lsfg_vk/config_schema.py')
| -rw-r--r-- | py_modules/lsfg_vk/config_schema.py | 67 |
1 files changed, 67 insertions, 0 deletions
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 @@ -316,6 +316,73 @@ class ConfigurationManager: 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, experimental_present_mode: str = "fifo", |
