@@ -22,17 +22,14 @@ def get_config(self) -> ConfigurationResponse:
2222 ConfigurationResponse with current configuration or error
2323 """
2424 try :
25- # Get TOML configuration (with defaults if file doesn't exist)
2625 if not self .config_file_path .exists ():
27- # Return default configuration with DLL detection if file doesn't exist
2826 from .dll_detection import DllDetectionService
2927 dll_service = DllDetectionService (self .log )
3028 toml_config = ConfigurationManager .get_defaults_with_dll_detection (dll_service )
3129 else :
3230 content = self .config_file_path .read_text (encoding = 'utf-8' )
3331 toml_config = ConfigurationManager .parse_toml_content (content )
3432
35- # Get script environment variables (if script exists)
3633 script_values = {}
3734 if self .lsfg_script_path .exists ():
3835 try :
@@ -42,7 +39,6 @@ def get_config(self) -> ConfigurationResponse:
4239 except Exception as e :
4340 self .log .warning (f"Failed to parse launch script: { str (e )} " )
4441
45- # Merge TOML config with script values
4642 config = ConfigurationManager .merge_config_with_script (toml_config , script_values )
4743
4844 return self ._success_response (ConfigurationResponse , config = config )
@@ -54,7 +50,6 @@ def get_config(self) -> ConfigurationResponse:
5450 except Exception as e :
5551 error_msg = f"Error parsing config file: { str (e )} "
5652 self .log .error (error_msg )
57- # Return defaults with DLL detection if parsing fails
5853 from .dll_detection import DllDetectionService
5954 dll_service = DllDetectionService (self .log )
6055 config = ConfigurationManager .get_defaults_with_dll_detection (dll_service )
@@ -75,7 +70,6 @@ def update_config_from_dict(self, config: ConfigurationData) -> ConfigurationRes
7570 profile_data = self ._get_profile_data ()
7671 current_profile = profile_data ["current_profile" ]
7772
78- # Update the current profile's config
7973 return self .update_profile_config (current_profile , config )
8074
8175 except (OSError , IOError ) as e :
@@ -97,10 +91,8 @@ def update_config(self, **kwargs) -> ConfigurationResponse:
9791 ConfigurationResponse with success status
9892 """
9993 try :
100- # Create configuration from keyword arguments using generated function
10194 config = ConfigurationManager .create_config_from_args (** kwargs )
10295
103- # Update using the new profile-aware method
10496 return self .update_config_from_dict (config )
10597
10698 except (OSError , IOError ) as e :
@@ -112,45 +104,6 @@ def update_config(self, **kwargs) -> ConfigurationResponse:
112104 self .log .error (error_msg )
113105 return self ._error_response (ConfigurationResponse , str (e ), config = None )
114106
115- def update_dll_path (self , dll_path : str ) -> ConfigurationResponse :
116- """Update just the DLL path in the configuration
117-
118- Args:
119- dll_path: Path to the Lossless.dll file
120-
121- Returns:
122- ConfigurationResponse with success status
123- """
124- try :
125- profile_data = self ._get_profile_data ()
126-
127- # Update global config (DLL path is global)
128- profile_data ["global_config" ]["dll" ] = dll_path
129-
130- # Also update current profile's config for backward compatibility
131- current_profile = profile_data ["current_profile" ]
132- from .config_schema_generated import DLL
133- profile_data ["profiles" ][current_profile ][DLL ] = dll_path
134-
135- # Save to file
136- self ._save_profile_data (profile_data )
137-
138- # Update launch script
139- script_result = self .update_lsfg_script_from_profile_data (profile_data )
140- if not script_result ["success" ]:
141- self .log .warning (f"Failed to update launch script: { script_result ['error' ]} " )
142-
143- self .log .info (f"Updated DLL path in lsfg configuration: '{ dll_path } '" )
144-
145- return self ._success_response (ConfigurationResponse ,
146- f"DLL path updated to: { dll_path } " ,
147- config = profile_data ["profiles" ][current_profile ])
148-
149- except Exception as e :
150- error_msg = f"Error updating DLL path: { str (e )} "
151- self .log .error (error_msg )
152- return self ._error_response (ConfigurationResponse , str (e ), config = None )
153-
154107 def update_lsfg_script (self , config : ConfigurationData ) -> ConfigurationResponse :
155108 """Update the ~/lsfg launch script with current configuration
156109
@@ -163,7 +116,6 @@ def update_lsfg_script(self, config: ConfigurationData) -> ConfigurationResponse
163116 try :
164117 script_content = self ._generate_script_content (config )
165118
166- # Write the script file
167119 self ._write_file (self .lsfg_script_path , script_content , 0o755 )
168120
169121 self .log .info (f"Updated lsfg launch script at { self .lsfg_script_path } " )
@@ -189,14 +141,12 @@ def _generate_script_content(self, config: ConfigurationData) -> str:
189141 lines = [
190142 "#!/bin/bash" ,
191143 "# lsfg-vk launch script generated by decky-lossless-scaling-vk plugin" ,
192- "# This script sets up the environment for lsfg-vk to work with the plugin configuration"
144+ "# This script sets up the environment for lsfg-vk to work with the plugin configuration" ,
193145 ]
194146
195- # Use auto-generated script generation logic
196147 generate_script_lines = get_script_generation_logic ()
197148 lines .extend (generate_script_lines (config ))
198149
199- # Always add the LSFG_PROCESS export and execution line
200150 lines .extend ([
201151 "export LSFG_PROCESS=decky-lsfg-vk" ,
202152 'exec "$@"'
@@ -216,23 +166,18 @@ def _generate_script_content_for_profile(self, profile_data: ProfileData) -> str
216166 current_profile = profile_data ["current_profile" ]
217167 config = profile_data ["profiles" ].get (current_profile , ConfigurationManager .get_defaults ())
218168
219- # Merge global config with profile config
220169 merged_config = dict (config )
221170 for field_name , value in profile_data ["global_config" ].items ():
222171 merged_config [field_name ] = value
223172
224173 lines = [
225174 "#!/bin/bash" ,
226- "# lsfg-vk launch script generated by decky-lossless-scaling-vk plugin" ,
227175 f"# Current profile: { current_profile } " ,
228- "# This script sets up the environment for lsfg-vk to work with the plugin configuration"
229176 ]
230177
231- # Use auto-generated script generation logic
232178 generate_script_lines = get_script_generation_logic ()
233179 lines .extend (generate_script_lines (merged_config ))
234180
235- # Export LSFG_PROCESS with current profile name
236181 lines .extend ([
237182 f"export LSFG_PROCESS={ current_profile } " ,
238183 'exec "$@"'
@@ -243,7 +188,6 @@ def _generate_script_content_for_profile(self, profile_data: ProfileData) -> str
243188 def _get_profile_data (self ) -> ProfileData :
244189 """Get current profile data from config file"""
245190 if not self .config_file_path .exists ():
246- # Return default profile structure if file doesn't exist
247191 from .dll_detection import DllDetectionService
248192 dll_service = DllDetectionService (self .log )
249193 default_config = ConfigurationManager .get_defaults_with_dll_detection (dll_service )
@@ -263,13 +207,10 @@ def _save_profile_data(self, profile_data: ProfileData) -> None:
263207 """Save profile data to config file"""
264208 toml_content = ConfigurationManager .generate_toml_content_multi_profile (profile_data )
265209
266- # Ensure config directory exists
267210 self .config_dir .mkdir (parents = True , exist_ok = True )
268211
269- # Write the updated config directly to preserve inode for file watchers
270212 self ._write_file (self .config_file_path , toml_content , 0o644 )
271213
272- # Profile management methods
273214 def get_profiles (self ) -> ProfilesResponse :
274215 """Get list of all profiles and current profile
275216
@@ -303,14 +244,11 @@ def create_profile(self, profile_name: str, source_profile: str = None) -> Profi
303244 try :
304245 profile_data = self ._get_profile_data ()
305246
306- # Use current profile as source if not specified
307247 if not source_profile :
308248 source_profile = profile_data ["current_profile" ]
309249
310- # Create the new profile
311250 new_profile_data = ConfigurationManager .create_profile (profile_data , profile_name , source_profile )
312251
313- # Save to file
314252 self ._save_profile_data (new_profile_data )
315253
316254 self .log .info (f"Created profile '{ profile_name } ' from '{ source_profile } '" )
@@ -340,13 +278,10 @@ def delete_profile(self, profile_name: str) -> ProfileResponse:
340278 try :
341279 profile_data = self ._get_profile_data ()
342280
343- # Delete the profile
344281 new_profile_data = ConfigurationManager .delete_profile (profile_data , profile_name )
345282
346- # Save to file
347283 self ._save_profile_data (new_profile_data )
348284
349- # Update launch script if current profile changed
350285 script_result = self .update_lsfg_script_from_profile_data (new_profile_data )
351286 if not script_result ["success" ]:
352287 self .log .warning (f"Failed to update launch script: { script_result ['error' ]} " )
@@ -379,13 +314,10 @@ def rename_profile(self, old_name: str, new_name: str) -> ProfileResponse:
379314 try :
380315 profile_data = self ._get_profile_data ()
381316
382- # Rename the profile
383317 new_profile_data = ConfigurationManager .rename_profile (profile_data , old_name , new_name )
384318
385- # Save to file
386319 self ._save_profile_data (new_profile_data )
387320
388- # Update launch script if current profile changed
389321 script_result = self .update_lsfg_script_from_profile_data (new_profile_data )
390322 if not script_result ["success" ]:
391323 self .log .warning (f"Failed to update launch script: { script_result ['error' ]} " )
@@ -417,13 +349,10 @@ def set_current_profile(self, profile_name: str) -> ProfileResponse:
417349 try :
418350 profile_data = self ._get_profile_data ()
419351
420- # Set current profile
421352 new_profile_data = ConfigurationManager .set_current_profile (profile_data , profile_name )
422353
423- # Save to file
424354 self ._save_profile_data (new_profile_data )
425355
426- # Update launch script with new current profile
427356 script_result = self .update_lsfg_script_from_profile_data (new_profile_data )
428357 if not script_result ["success" ]:
429358 self .log .warning (f"Failed to update launch script: { script_result ['error' ]} " )
@@ -469,16 +398,13 @@ def update_profile_config(self, profile_name: str, config: ConfigurationData) ->
469398 if field_name in config :
470399 profile_data ["global_config" ][field_name ] = config [field_name ]
471400
472- # Save to file
473401 self ._save_profile_data (profile_data )
474402
475- # Update launch script if this is the current profile
476403 if profile_name == profile_data ["current_profile" ]:
477404 script_result = self .update_lsfg_script_from_profile_data (profile_data )
478405 if not script_result ["success" ]:
479406 self .log .warning (f"Failed to update launch script: { script_result ['error' ]} " )
480407
481- # Log with dynamic field listing
482408 field_values = ", " .join (f"{ k } ={ repr (v )} " for k , v in config .items ())
483409 self .log .info (f"Updated profile '{ profile_name } ' configuration: { field_values } " )
484410
0 commit comments