summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwuriko <noahfenghom@gmail.com>2026-02-08 15:08:04 +0100
committerwuriko <noahfenghom@gmail.com>2026-02-08 15:08:04 +0100
commit62df0441f1ddc83c31dccc7cf9c62a762aed4994 (patch)
tree97cfb2f5f8f954a7e26d52e0bee2d1f4a3a8a8a0
parente6c32d27db7075d66ecef33f368bdd69d3b035d0 (diff)
downloadDecky-Framegen-62df0441f1ddc83c31dccc7cf9c62a762aed4994.tar.gz
Decky-Framegen-62df0441f1ddc83c31dccc7cf9c62a762aed4994.zip
feat: add support for optiscaler config variables
-rwxr-xr-xdefaults/assets/fgmod.sh5
-rw-r--r--defaults/assets/update-optiscaler-config.py66
-rw-r--r--main.py9
3 files changed, 80 insertions, 0 deletions
diff --git a/defaults/assets/fgmod.sh b/defaults/assets/fgmod.sh
index d48856d..efe1ef2 100755
--- a/defaults/assets/fgmod.sh
+++ b/defaults/assets/fgmod.sh
@@ -128,6 +128,11 @@ else
logger -t fgmod "📄 OptiScaler.ini installed to $exe_folder_path"
fi
+# === OptiScaler env variables Handling ===
+if command -v python &> /dev/null && [ -f "$fgmod_path/update-optiscaler-config.py" ]; then
+ python "$fgmod_path/update-optiscaler-config.py" "$exe_folder_path/OptiScaler.ini"
+fi
+
# === ASI Plugins Directory ===
if [[ -d "$fgmod_path/plugins" ]]; then
echo "🔌 Installing ASI plugins directory"
diff --git a/defaults/assets/update-optiscaler-config.py b/defaults/assets/update-optiscaler-config.py
new file mode 100644
index 0000000..9c00ee1
--- /dev/null
+++ b/defaults/assets/update-optiscaler-config.py
@@ -0,0 +1,66 @@
+import os
+import sys
+import re
+
+def update_optiscaler_config(file_path):
+ if not os.path.exists(file_path):
+ print(f"Error: File '{file_path}' not found.")
+ return
+
+ with open(file_path, 'r') as f:
+ lines = f.readlines()
+
+ # Get environment variables starting with OptiScaler_
+ env_vars = {k: v for k, v in os.environ.items() if k.startswith("OptiScaler_")}
+
+ for env_name, env_value in env_vars.items():
+ # Split OptiScaler_Section_Key
+ parts = env_name.split('_', 2)
+ if len(parts) < 3:
+ continue
+
+ section_target = parts[1]
+ key_target = parts[2]
+
+ found_section = False
+ updated_key = False
+
+ # Regex to match [Section] and Key=Value
+ section_pattern = re.compile(rf'^\s*\[{re.escape(section_target)}\]\s*')
+ key_pattern = re.compile(rf'^(\s*{re.escape(key_target)}\s*)=.*')
+
+ for i, line in enumerate(lines):
+ # Track if we are inside the correct section
+ if section_pattern.match(line):
+ found_section = True
+ continue
+
+ # If we hit a new section before finding the key, the key doesn't exist in the target section
+ if found_section and line.strip().startswith('[') and not section_pattern.match(line):
+ break
+
+ # Replace the value if the key is found within the correct section
+ if found_section and key_pattern.match(line):
+ lines[i] = key_pattern.sub(r'\1=' + env_value, line)
+ updated_key = True
+ print(f"Updated: [{section_target}] {key_target} = {env_value}")
+ break
+
+ # If section exists but key doesn't, append key to the end of the section
+ # Not really needed but supported just in case
+ if found_section and not updated_key:
+ for i, line in enumerate(lines):
+ if section_pattern.match(line):
+ lines.insert(i + 1, f"{key_target}={env_value}\n")
+ print(f"Added new key: [{section_target}] {key_target} = {env_value}")
+ break
+
+ # Write the modified content back
+ with open(file_path, 'w') as f:
+ f.writelines(lines)
+
+if __name__ == "__main__":
+ if len(sys.argv) < 2:
+ print("Usage: python update-optiscaler-config.py <path_to_ini>")
+ else:
+ update_optiscaler_config(sys.argv[1]) \ No newline at end of file
diff --git a/main.py b/main.py
index 5b6b8e8..5a9c874 100644
--- a/main.py
+++ b/main.py
@@ -114,6 +114,14 @@ class Plugin:
shutil.copy2(uninstaller_src, uninstaller_dest)
uninstaller_dest.chmod(0o755)
decky.logger.info(f"Copied uninstaller script to {uninstaller_dest}")
+
+ # Copy optiscaler config updater script
+ optiscaler_config_updater_src = assets_dir / "update-optiscaler-config.py"
+ optiscaler_config_updater_dest = extract_path / "update-optiscaler-config.py"
+ if optiscaler_config_updater_src.exists():
+ shutil.copy2(optiscaler_config_updater_src, optiscaler_config_updater_dest)
+ optiscaler_config_updater_dest.chmod(0o755)
+ decky.logger.info(f"Copied update-optiscaler-config.py script to {optiscaler_config_updater_dest}")
return True
except Exception as e:
@@ -413,6 +421,7 @@ class Plugin:
"libxell.dll", # New in v0.9.0-pre4
"fgmod",
"fgmod-uninstaller.sh"
+ "update-optiscaler-config.py"
]
if path.exists():