diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-17 14:35:06 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-17 14:35:06 -0400 |
| commit | 57bd1cd9fcbbc8d4cd1d2f45106fc29d00bb6918 (patch) | |
| tree | 3acac7bcad782af3f70a2fbd114ac63dff5919f5 /py_modules/lsfg_vk | |
| parent | 6b701637ad308513b678c80baceec6c79e339ce9 (diff) | |
| download | decky-lsfg-vk-57bd1cd9fcbbc8d4cd1d2f45106fc29d00bb6918.tar.gz decky-lsfg-vk-57bd1cd9fcbbc8d4cd1d2f45106fc29d00bb6918.zip | |
write dll path when discovered
Diffstat (limited to 'py_modules/lsfg_vk')
| -rw-r--r-- | py_modules/lsfg_vk/config_schema.py | 30 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/configuration.py | 18 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/installation.py | 16 |
3 files changed, 53 insertions, 11 deletions
diff --git a/py_modules/lsfg_vk/config_schema.py b/py_modules/lsfg_vk/config_schema.py index f054abf..8c5f58c 100644 --- a/py_modules/lsfg_vk/config_schema.py +++ b/py_modules/lsfg_vk/config_schema.py @@ -48,7 +48,7 @@ CONFIG_SCHEMA: Dict[str, ConfigField] = { "dll": ConfigField( name="dll", field_type=ConfigFieldType.STRING, - default="/games/Lossless Scaling/Lossless.dll", + default="", # Will be populated dynamically based on detection description="specify where Lossless.dll is stored" ), @@ -104,6 +104,34 @@ class ConfigurationManager: }) @staticmethod + def get_defaults_with_dll_detection(dll_detection_service=None) -> ConfigurationData: + """Get default configuration values with DLL path detection + + Args: + dll_detection_service: Optional DLL detection service instance + + Returns: + ConfigurationData with detected DLL path if available + """ + defaults = ConfigurationManager.get_defaults() + + # Try to detect DLL path if service provided + if dll_detection_service: + try: + dll_result = dll_detection_service.check_lossless_scaling_dll() + if dll_result.get("detected") and dll_result.get("path"): + defaults["dll"] = dll_result["path"] + except Exception: + # If detection fails, keep empty default + pass + + # If DLL path is still empty, use a reasonable fallback + if not defaults["dll"]: + defaults["dll"] = "/home/deck/.local/share/Steam/steamapps/common/Lossless Scaling/Lossless.dll" + + return defaults + + @staticmethod def get_field_names() -> list[str]: """Get ordered list of configuration field names""" return list(CONFIG_SCHEMA.keys()) diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index 4d76a30..c15fc37 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -21,8 +21,10 @@ class ConfigurationService(BaseService): """ try: if not self.config_file_path.exists(): - # Return default configuration if file doesn't exist - config = ConfigurationManager.get_defaults() + # Return default configuration with DLL detection if file doesn't exist + from .dll_detection import DllDetectionService + dll_service = DllDetectionService(self.log) + config = ConfigurationManager.get_defaults_with_dll_detection(dll_service) return { "success": True, "config": config, @@ -52,8 +54,10 @@ class ConfigurationService(BaseService): except Exception as e: error_msg = f"Error parsing config file: {str(e)}" self.log.error(error_msg) - # Return defaults if parsing fails - config = ConfigurationManager.get_defaults() + # Return defaults with DLL detection if parsing fails + from .dll_detection import DllDetectionService + dll_service = DllDetectionService(self.log) + config = ConfigurationManager.get_defaults_with_dll_detection(dll_service) return { "success": True, "config": config, @@ -134,8 +138,10 @@ class ConfigurationService(BaseService): # Get current config current_response = self.get_config() if not current_response["success"] or current_response["config"] is None: - # If we can't read current config, use defaults - config = ConfigurationManager.get_defaults() + # If we can't read current config, use defaults with DLL detection + from .dll_detection import DllDetectionService + dll_service = DllDetectionService(self.log) + config = ConfigurationManager.get_defaults_with_dll_detection(dll_service) else: config = current_response["config"] diff --git a/py_modules/lsfg_vk/installation.py b/py_modules/lsfg_vk/installation.py index a1c2d64..27be850 100644 --- a/py_modules/lsfg_vk/installation.py +++ b/py_modules/lsfg_vk/installation.py @@ -103,16 +103,24 @@ class InstallationService(BaseService): self.log.info(f"Copied {file} to {dst_file}") def _create_config_file(self) -> None: - """Create the TOML config file in ~/.config/lsfg-vk with default configuration""" - # Get default configuration - defaults = ConfigurationManager.get_defaults() + """Create the TOML config file in ~/.config/lsfg-vk with default configuration and detected DLL path""" + # Import here to avoid circular imports + from .dll_detection import DllDetectionService + + # Try to detect DLL path + dll_service = DllDetectionService(self.log) + config = ConfigurationManager.get_defaults_with_dll_detection(dll_service) # Generate TOML content using centralized manager - toml_content = ConfigurationManager.generate_toml_content(defaults) + toml_content = ConfigurationManager.generate_toml_content(config) # Use atomic write to prevent corruption self._atomic_write(self.config_file_path, toml_content, 0o644) self.log.info(f"Created config file at {self.config_file_path}") + + # Log detected DLL path if found + if config["dll"]: + self.log.info(f"Configured DLL path: {config['dll']}") def check_installation(self) -> InstallationCheckResponse: """Check if lsfg-vk is already installed |
