diff options
| -rw-r--r-- | main.py | 56 | ||||
| -rwxr-xr-x | src/index.tsx | 34 |
2 files changed, 80 insertions, 10 deletions
@@ -86,16 +86,22 @@ export LSFG_FLOW_SCALE=1.0 user_home = os.path.expanduser("~") lib_file = os.path.join(user_home, ".local", "lib", "liblsfg-vk.so") json_file = os.path.join(user_home, ".local", "share", "vulkan", "implicit_layer.d", "VkLayer_LS_frame_generation.json") + lsfg_script = os.path.join(user_home, "lsfg") lib_exists = os.path.exists(lib_file) json_exists = os.path.exists(json_file) + script_exists = os.path.exists(lsfg_script) + + decky.logger.info(f"Installation check: lib={lib_exists}, json={json_exists}, script={script_exists}") return { "installed": lib_exists and json_exists, "lib_exists": lib_exists, "json_exists": json_exists, + "script_exists": script_exists, "lib_path": lib_file, - "json_path": json_file + "json_path": json_file, + "script_path": lsfg_script } except Exception as e: @@ -224,22 +230,56 @@ export LSFG_FLOW_SCALE=1.0 lines = content.split('\n') for line in lines: line = line.strip() + + # Handle ENABLE_LSFG - check if it's commented out or not if line.startswith('export ENABLE_LSFG='): - config["enable_lsfg"] = line.split('=')[1] == '1' + try: + value = line.split('=')[1].strip() + config["enable_lsfg"] = value == '1' + except: + pass + elif line.startswith('# export ENABLE_LSFG='): + config["enable_lsfg"] = False + + # Handle LSFG_MULTIPLIER elif line.startswith('export LSFG_MULTIPLIER='): try: - config["multiplier"] = int(line.split('=')[1]) + value = line.split('=')[1].strip() + config["multiplier"] = int(value) except: - config["multiplier"] = 2 + pass + + # Handle LSFG_FLOW_SCALE elif line.startswith('export LSFG_FLOW_SCALE='): try: - config["flow_scale"] = float(line.split('=')[1]) + value = line.split('=')[1].strip() + config["flow_scale"] = float(value) except: - config["flow_scale"] = 1.0 + pass + + # Handle LSFG_HDR - check if it's commented out or not elif line.startswith('export LSFG_HDR='): - config["hdr"] = line.split('=')[1] == '1' + try: + value = line.split('=')[1].strip() + config["hdr"] = value == '1' + except: + pass + elif line.startswith('# export LSFG_HDR='): + config["hdr"] = False + + # Handle MESA_VK_WSI_PRESENT_MODE - check if it's commented out or not elif line.startswith('export MESA_VK_WSI_PRESENT_MODE='): - config["immediate_mode"] = line.split('=')[1].strip() == 'immediate' + try: + value = line.split('=')[1].strip() + # Remove any comments after the value + value = value.split('#')[0].strip() + config["immediate_mode"] = value == 'immediate' + except: + pass + elif line.startswith('# export MESA_VK_WSI_PRESENT_MODE='): + config["immediate_mode"] = False + + decky.logger.info(f"Parsed lsfg config: {config}") return { "success": True, diff --git a/src/index.tsx b/src/index.tsx index 0c706d8..aeb9e2b 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -22,7 +22,7 @@ const installLsfgVk = callable<[], { success: boolean; error?: string; message?: const uninstallLsfgVk = callable<[], { success: boolean; error?: string; message?: string; removed_files?: string[] }>("uninstall_lsfg_vk"); // Function to check if lsfg-vk is installed -const checkLsfgVkInstalled = callable<[], { installed: boolean; lib_exists: boolean; json_exists: boolean; lib_path: string; json_path: string; error?: string }>("check_lsfg_vk_installed"); +const checkLsfgVkInstalled = callable<[], { installed: boolean; lib_exists: boolean; json_exists: boolean; script_exists: boolean; lib_path: string; json_path: string; script_path: string; error?: string }>("check_lsfg_vk_installed"); // Function to check if Lossless Scaling DLL is available const checkLosslessScalingDll = callable<[], { detected: boolean; path?: string; source?: string; message?: string; error?: string }>("check_lossless_scaling_dll"); @@ -87,6 +87,10 @@ function Content() { setFlowScale(result.config.flow_scale); setHdr(result.config.hdr); setImmediateMode(result.config.immediate_mode); + console.log("Loaded lsfg config:", result.config); + } else { + // If script doesn't exist or can't be read, keep default values + console.log("lsfg config not available, using defaults:", result.error); } } catch (error) { console.error("Error loading lsfg config:", error); @@ -95,8 +99,34 @@ function Content() { checkInstallation(); checkDllDetection(); + + // Always try to load config, regardless of installation status + // This handles cases where the script exists but plugin shows as not installed loadLsfgConfig(); - }, []); const handleInstall = async () => { + }, []); + + // Add a second useEffect to reload config when isInstalled changes + // This ensures UI reflects script state when plugin detects installation + useEffect(() => { + if (isInstalled) { + const reloadConfig = async () => { + try { + const result = await getLsfgConfig(); + if (result.success && result.config) { + setEnableLsfg(result.config.enable_lsfg); + setMultiplier(result.config.multiplier); + setFlowScale(result.config.flow_scale); + setHdr(result.config.hdr); + setImmediateMode(result.config.immediate_mode); + console.log("Reloaded lsfg config after installation detected:", result.config); + } + } catch (error) { + console.error("Error reloading lsfg config:", error); + } + }; + reloadConfig(); + } + }, [isInstalled]); const handleInstall = async () => { setIsInstalling(true); setInstallationStatus("Installing lsfg-vk..."); |
