summaryrefslogtreecommitdiff
path: root/py_modules
diff options
context:
space:
mode:
authorxXJSONDeruloXx <danielhimebauch@gmail.com>2026-09-06 15:08:45 -0400
committerxXJSONDeruloXx <danielhimebauch@gmail.com>2026-09-06 15:09:20 -0400
commitad2b182777bfd0a5ceef6e654df75ff13eb8b503 (patch)
tree7b98bfe322f18e59c74d7b3a0745608390a0a0fd /py_modules
parenta9fd67d05d6819a839a60b581c1dc6eb2792a9be (diff)
downloaddecky-lsfg-vk-ad2b182777bfd0a5ceef6e654df75ff13eb8b503.tar.gz
decky-lsfg-vk-ad2b182777bfd0a5ceef6e654df75ff13eb8b503.zip
refactor: offload configuration to lsfg-vk
Diffstat (limited to 'py_modules')
-rw-r--r--py_modules/lsfg_vk/config_schema.py376
-rw-r--r--py_modules/lsfg_vk/config_schema_generated.py123
-rw-r--r--py_modules/lsfg_vk/configuration.py289
-rw-r--r--py_modules/lsfg_vk/installation.py52
-rw-r--r--py_modules/lsfg_vk/plugin.py89
-rw-r--r--py_modules/lsfg_vk/runtime_service.py2
-rw-r--r--py_modules/lsfg_vk/steam_service.py30
-rw-r--r--py_modules/lsfg_vk/types.py11
8 files changed, 310 insertions, 662 deletions
diff --git a/py_modules/lsfg_vk/config_schema.py b/py_modules/lsfg_vk/config_schema.py
index e39be54..4ae1f4c 100644
--- a/py_modules/lsfg_vk/config_schema.py
+++ b/py_modules/lsfg_vk/config_schema.py
@@ -1,49 +1,37 @@
+"""Small adapter for the upstream lsfg-vk v2 configuration format."""
+
import json
-import re
-import shlex
import sys
import tomllib
-from dataclasses import dataclass
from pathlib import Path
-from typing import Any, Dict, TypedDict, Union, cast
+from typing import Any, Dict, TypedDict, cast
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
-from shared_config import CONFIG_SCHEMA_DEF, ConfigFieldType, get_defaults
-from .config_schema_generated import ConfigurationData, get_script_parsing_logic
-
-
-@dataclass
-class ConfigField:
- name: str
- field_type: ConfigFieldType
- default: Union[bool, int, float, str]
- description: str
-
-CONFIG_SCHEMA: Dict[str, ConfigField] = {
- name: ConfigField(
- name=definition["name"],
- field_type=ConfigFieldType(definition["fieldType"]),
- default=definition["default"],
- description=definition["description"],
- )
- for name, definition in CONFIG_SCHEMA_DEF.items()
-}
-
-SCRIPT_ONLY_FIELDS = {
- name
- for name, definition in CONFIG_SCHEMA_DEF.items()
- if definition["location"] == "script"
-}
-DEFAULT_PROFILE_NAME = "decky-lsfg-vk"
+DEFAULT_PROFILE_NAME = "default"
+ConfigurationData = Dict[str, Any]
class ProfileData(TypedDict):
+ # Internal compatibility field; the public API no longer exposes a
+ # currently selected profile.
current_profile: str
profiles: Dict[str, Dict[str, Any]]
global_config: Dict[str, Any]
+PROFILE_DEFAULTS: Dict[str, Any] = {
+ "active_in": [],
+ "pacing_mode": "vsync",
+ "multiplier": 2,
+ "flow_scale": 1.0,
+ "performance_mode": False,
+ "override_present_mode": True,
+ "preserve_swapchain_image_count": False,
+}
+GLOBAL_DEFAULTS: Dict[str, Any] = {"dll": "", "no_fp16": False}
+
+
def _toml_value(value: Any) -> str:
if isinstance(value, bool):
return str(value).lower()
@@ -54,41 +42,52 @@ def _toml_value(value: Any) -> str:
return str(value)
+def _normalize_active_in(value: Any) -> list[str]:
+ if value in (None, ""):
+ return []
+ if isinstance(value, str):
+ return [value]
+ if not isinstance(value, list):
+ raise ValueError("active_in must be a string or list of strings")
+ return [str(item) for item in value if str(item)]
+
+
class ConfigurationManager:
@staticmethod
- def get_defaults() -> ConfigurationData:
- return cast(ConfigurationData, dict(get_defaults()))
+ def get_defaults() -> Dict[str, Any]:
+ return {**GLOBAL_DEFAULTS, **PROFILE_DEFAULTS}
@staticmethod
def get_field_names() -> list[str]:
- return list(CONFIG_SCHEMA)
+ return list(ConfigurationManager.get_defaults())
@staticmethod
- def get_field_types() -> Dict[str, ConfigFieldType]:
- return {name: field.field_type for name, field in CONFIG_SCHEMA.items()}
+ def get_field_types() -> Dict[str, str]:
+ return {
+ "dll": "string", "no_fp16": "boolean", "active_in": "array",
+ "pacing_mode": "string", "multiplier": "integer", "flow_scale": "float",
+ "performance_mode": "boolean", "override_present_mode": "boolean",
+ "preserve_swapchain_image_count": "boolean",
+ }
@staticmethod
- def validate_config(config: Dict[str, Any]) -> ConfigurationData:
- validated: Dict[str, Any] = {}
- for name, field in CONFIG_SCHEMA.items():
- value = config.get(name, field.default)
- if field.field_type == ConfigFieldType.BOOLEAN:
- value = value.lower() in {"true", "1", "yes", "on"} if isinstance(value, str) else bool(value)
- elif field.field_type == ConfigFieldType.INTEGER:
- value = int(value)
- elif field.field_type == ConfigFieldType.FLOAT:
- value = float(value)
- else:
- value = str(value)
- validated[name] = value
-
- if validated["multiplier"] < 1:
+ def validate_config(config: Dict[str, Any]) -> Dict[str, Any]:
+ result = {**PROFILE_DEFAULTS, **GLOBAL_DEFAULTS}
+ result.update({key: value for key, value in config.items() if key in result})
+ result["active_in"] = _normalize_active_in(result.get("active_in"))
+ result["pacing_mode"] = str(result.get("pacing_mode", "vsync")).lower()
+ if result["pacing_mode"] != "vsync":
+ raise ValueError("pacing_mode must be vsync")
+ result["multiplier"] = int(result["multiplier"])
+ if result["multiplier"] < 1:
raise ValueError("multiplier must be 1 or greater")
- if not 0.25 <= validated["flow_scale"] <= 1.0:
+ result["flow_scale"] = float(result["flow_scale"])
+ if not 0.25 <= result["flow_scale"] <= 1.0:
raise ValueError("flow_scale must be between 0.25 and 1.0")
- if validated["experimental_present_mode"] not in {"fifo", "mailbox"}:
- raise ValueError("experimental_present_mode must be fifo or mailbox")
- return cast(ConfigurationData, validated)
+ for name in ("no_fp16", "performance_mode", "override_present_mode", "preserve_swapchain_image_count"):
+ result[name] = bool(result[name])
+ result["dll"] = str(result.get("dll") or "")
+ return result
@staticmethod
def _migrate_dll_path(value: Any) -> str:
@@ -102,246 +101,81 @@ class ConfigurationManager:
@staticmethod
def _config_from_profile(profile: Dict[str, Any], global_config: Dict[str, Any]) -> Dict[str, Any]:
- config: Dict[str, Any] = dict(ConfigurationManager.get_defaults())
- for field in ("multiplier", "flow_scale", "performance_mode"):
- if field in profile:
- config[field] = profile[field]
- config["experimental_present_mode"] = "fifo" if bool(profile.get("override_present_mode", True)) else "mailbox"
- config["dll"] = global_config.get("dll", "")
- config["no_fp16"] = global_config.get("no_fp16", False)
- for field in ("active_in", "pacing", "preserve_swapchain_image_count"):
- if field in profile:
- config[field] = profile[field]
- return {**config, **ConfigurationManager.validate_config(config)}
-
- @staticmethod
- def generate_toml_content(config: ConfigurationData) -> str:
- profile_data: ProfileData = {
+ raw = dict(profile)
+ if "pacing_mode" not in raw and "pacing" in raw:
+ raw["pacing_mode"] = raw["pacing"]
+ if "override_present_mode" not in raw and "experimental_present_mode" in raw:
+ raw["override_present_mode"] = raw["experimental_present_mode"] == "fifo"
+ raw["dll"] = global_config.get("dll", "")
+ raw["no_fp16"] = global_config.get("no_fp16", False)
+ return ConfigurationManager.validate_config(raw)
+
+ @staticmethod
+ def generate_toml_content(config: Dict[str, Any]) -> str:
+ data: ProfileData = {
"current_profile": DEFAULT_PROFILE_NAME,
"profiles": {DEFAULT_PROFILE_NAME: dict(config)},
- "global_config": {
- "dll": config.get("dll", ""),
- "no_fp16": config.get("no_fp16", False),
- },
+ "global_config": {"dll": config.get("dll", ""), "no_fp16": config.get("no_fp16", False)},
}
- return ConfigurationManager.generate_toml_content_multi_profile(profile_data)
+ return ConfigurationManager.generate_toml_content_multi_profile(data)
@staticmethod
def generate_toml_content_multi_profile(profile_data: ProfileData) -> str:
- global_config = profile_data["global_config"]
+ global_config = {**GLOBAL_DEFAULTS, **profile_data.get("global_config", {})}
lines = ["version = 2", "", "[global]"]
- dll = ConfigurationManager._migrate_dll_path(global_config.get("dll", ""))
+ dll = ConfigurationManager._migrate_dll_path(global_config.get("dll"))
if dll:
lines.append(f"dll = {_toml_value(dll)}")
lines.append(f"allow_fp16 = {_toml_value(not bool(global_config.get('no_fp16', False)))}")
- if global_config.get("log_level"):
- lines.append(f"log_level = {_toml_value(global_config['log_level'])}")
- if global_config.get("log_file"):
- lines.append(f"log_file = {_toml_value(global_config['log_file'])}")
-
- profiles = sorted(
- profile_data["profiles"].items(),
- key=lambda item: (item[0] != DEFAULT_PROFILE_NAME, item[0]),
- )
- for profile_name, raw_config in profiles:
- config = ConfigurationManager.validate_config(raw_config)
- lines.extend(["", "[[profile]]", f"name = {_toml_value(profile_name)}"])
- active_in = raw_config.get("active_in")
- if active_in not in (None, "", []):
- lines.append(f"active_in = {_toml_value(active_in)}")
- lines.extend(
- [
- f"multiplier = {config['multiplier']}",
- f"flow_scale = {config['flow_scale']}",
- f"performance_mode = {_toml_value(config['performance_mode'])}",
- f"pacing = {_toml_value(raw_config.get('pacing', 'vsync'))}",
- f"override_present_mode = {_toml_value(config['experimental_present_mode'] == 'fifo')}",
- f"preserve_swapchain_image_count = {_toml_value(bool(raw_config.get('preserve_swapchain_image_count', False)))}",
- ]
- )
+ profiles = sorted(profile_data["profiles"].items(), key=lambda item: (item[0] != DEFAULT_PROFILE_NAME, item[0]))
+ for name, raw in profiles:
+ config = ConfigurationManager.validate_config({**raw, **global_config})
+ lines.extend(["", "[[profile]]", f"name = {_toml_value(name)}"])
+ if config["active_in"]:
+ lines.append(f"active_in = {_toml_value(config['active_in'])}")
+ lines.extend([
+ f"pacing_mode = {_toml_value(config['pacing_mode'])}",
+ f"multiplier = {config['multiplier']}",
+ f"flow_scale = {config['flow_scale']}",
+ f"performance_mode = {_toml_value(config['performance_mode'])}",
+ f"override_present_mode = {_toml_value(config['override_present_mode'])}",
+ f"preserve_swapchain_image_count = {_toml_value(config['preserve_swapchain_image_count'])}",
+ ])
return "\n".join(lines) + "\n"
@staticmethod
- def _profile_data_from_v1(data: Dict[str, Any]) -> ProfileData:
- old_global = dict(data.get("global", {}))
- global_config: Dict[str, Any] = {
- "dll": ConfigurationManager._migrate_dll_path(old_global.get("dll", "")),
- "no_fp16": bool(old_global.get("no_fp16", False)),
- }
- profiles: Dict[str, Dict[str, Any]] = {}
- for game in data.get("game", []):
- profile_name = str(game.get("exe", DEFAULT_PROFILE_NAME))
- config: Dict[str, Any] = dict(ConfigurationManager.get_defaults())
- for field in ("multiplier", "flow_scale", "performance_mode", "experimental_present_mode"):
- if field in game:
- config[field] = game[field]
- config["dll"] = global_config["dll"]
- config["no_fp16"] = global_config["no_fp16"]
- profiles[profile_name] = dict(ConfigurationManager.validate_config(config))
-
- if not profiles:
- profiles[DEFAULT_PROFILE_NAME] = dict(ConfigurationManager.get_defaults())
-
- current_profile = str(old_global.get("current_profile", DEFAULT_PROFILE_NAME))
- if current_profile not in profiles:
- current_profile = DEFAULT_PROFILE_NAME if DEFAULT_PROFILE_NAME in profiles else next(iter(profiles))
- return ProfileData(
- current_profile=current_profile,
- profiles=profiles,
- global_config=global_config,
- )
-
- @staticmethod
- def is_legacy_v1(content: str) -> bool:
- try:
- return tomllib.loads(content).get("version") == 1
- except tomllib.TOMLDecodeError:
- return False
-
- @staticmethod
def parse_toml_content_multi_profile(content: str) -> ProfileData:
data = tomllib.loads(content)
version = data.get("version")
- if version == 1:
- return ConfigurationManager._profile_data_from_v1(data)
- if version != 2:
+ if version not in (1, 2):
raise ValueError("unsupported lsfg-vk configuration version")
-
raw_global = dict(data.get("global", {}))
- global_config: Dict[str, Any] = {
+ global_config = {
"dll": ConfigurationManager._migrate_dll_path(raw_global.get("dll", "")),
"no_fp16": not bool(raw_global.get("allow_fp16", True)),
}
- for field in ("log_level", "log_file"):
- if field in raw_global:
- global_config[field] = raw_global[field]
-
profiles: Dict[str, Dict[str, Any]] = {}
- for profile in data.get("profile", []):
- profile_name = str(profile.get("name", DEFAULT_PROFILE_NAME))
- profiles[profile_name] = ConfigurationManager._config_from_profile(profile, global_config)
-
+ source_profiles = data.get("game", []) if version == 1 else data.get("profile", [])
+ for profile in source_profiles:
+ name = str(profile.get("exe" if version == 1 else "name", DEFAULT_PROFILE_NAME))
+ profiles[name] = ConfigurationManager._config_from_profile(profile, global_config)
if not profiles:
- default = dict(ConfigurationManager.get_defaults())
- default["dll"] = global_config["dll"]
- default["no_fp16"] = global_config["no_fp16"]
- profiles[DEFAULT_PROFILE_NAME] = default
-
- current_profile = DEFAULT_PROFILE_NAME if DEFAULT_PROFILE_NAME in profiles else next(iter(profiles))
- return ProfileData(
- current_profile=current_profile,
- profiles=profiles,
- global_config=global_config,
- )
-
- @staticmethod
- def parse_toml_content(content: str) -> ConfigurationData:
- profile_data = ConfigurationManager.parse_toml_content_multi_profile(content)
- return cast(ConfigurationData, profile_data["profiles"][profile_data["current_profile"]])
-
- @staticmethod
- def parse_script_content(script_content: str) -> Dict[str, Union[bool, int, str]]:
- return get_script_parsing_logic()(script_content.splitlines())
-
- @staticmethod
- def parse_profile_selection(script_content: str) -> str | None:
- selected = None
- for line in script_content.splitlines():
- try:
- tokens = shlex.split(line)
- except ValueError:
- continue
- if len(tokens) != 2 or tokens[0] != "export" or "=" not in tokens[1]:
- continue
- key, value = tokens[1].split("=", 1)
- if key in {"LSFGVK_PROFILE", "LSFG_PROCESS"} and value:
- selected = value
- return selected
-
- @staticmethod
- def merge_config_with_script(
- toml_config: Dict[str, Any],
- script_values: Dict[str, Union[bool, int, str]],
- ) -> Dict[str, Any]:
- merged = dict(toml_config)
- for field in SCRIPT_ONLY_FIELDS:
- if field in script_values:
- merged[field] = script_values[field]
- return merged
+ profiles[DEFAULT_PROFILE_NAME] = ConfigurationManager.validate_config(global_config)
+ elif DEFAULT_PROFILE_NAME not in profiles:
+ source = profiles.get("decky-lsfg-vk", next(iter(profiles.values())))
+ profiles[DEFAULT_PROFILE_NAME] = {**source, "active_in": []}
+ if profiles.get("decky-lsfg-vk", {}).get("active_in", []) == []:
+ profiles.pop("decky-lsfg-vk", None)
+ return {"current_profile": DEFAULT_PROFILE_NAME, "profiles": profiles, "global_config": global_config}
@staticmethod
- def normalize_profile_name(profile_name: str) -> str:
- return re.sub(r"\s+", "-", profile_name.strip()).strip("-")
-
- @staticmethod
- def validate_profile_name(profile_name: str) -> bool:
- normalized = ConfigurationManager.normalize_profile_name(profile_name)
- invalid = '\t\n\r\'"\\/$|&;()<>{}[]' + "`" + '*?'
- return (
- bool(normalized)
- and not any(character in invalid for character in normalized)
- and normalized.lower() not in {"global", "profile"}
- )
-
- @staticmethod
- def create_profile(profile_data: ProfileData, profile_name: str, source_profile: str = None) -> ProfileData:
- if not ConfigurationManager.validate_profile_name(profile_name):
- raise ValueError(f"Invalid profile name: {profile_name}")
- normalized = ConfigurationManager.normalize_profile_name(profile_name)
- if normalized in profile_data["profiles"]:
- raise ValueError(f"Profile '{normalized}' already exists")
- source = source_profile if source_profile in profile_data["profiles"] else profile_data["current_profile"]
- profiles = dict(profile_data["profiles"])
- profiles[normalized] = dict(profiles[source])
- return ProfileData(
- current_profile=profile_data["current_profile"],
- profiles=profiles,
- global_config=dict(profile_data["global_config"]),
- )
-
- @staticmethod
- def delete_profile(profile_data: ProfileData, profile_name: str) -> ProfileData:
- if profile_name == DEFAULT_PROFILE_NAME:
- raise ValueError("Cannot delete the default profile")
- if profile_name not in profile_data["profiles"]:
- raise ValueError(f"Profile '{profile_name}' does not exist")
- profiles = dict(profile_data["profiles"])
- del profiles[profile_name]
- current_profile = profile_data["current_profile"]
- if current_profile == profile_name:
- current_profile = DEFAULT_PROFILE_NAME if DEFAULT_PROFILE_NAME in profiles else next(iter(profiles))
- return ProfileData(
- current_profile=current_profile,
- profiles=profiles,
- global_config=dict(profile_data["global_config"]),
- )
-
- @staticmethod
- def rename_profile(profile_data: ProfileData, old_name: str, new_name: str) -> ProfileData:
- if old_name == DEFAULT_PROFILE_NAME:
- raise ValueError("Cannot rename the default profile")
- if old_name not in profile_data["profiles"] or not ConfigurationManager.validate_profile_name(new_name):
- raise ValueError("Invalid profile rename")
- normalized = ConfigurationManager.normalize_profile_name(new_name)
- if normalized in profile_data["profiles"]:
- raise ValueError(f"Profile '{normalized}' already exists")
- profiles = {
- normalized if name == old_name else name: value
- for name, value in profile_data["profiles"].items()
- }
- current_profile = normalized if profile_data["current_profile"] == old_name else profile_data["current_profile"]
- return ProfileData(
- current_profile=current_profile,
- profiles=profiles,
- global_config=dict(profile_data["global_config"]),
- )
+ def is_legacy_v1(content: str) -> bool:
+ try:
+ return tomllib.loads(content).get("version") == 1
+ except tomllib.TOMLDecodeError:
+ return False
@staticmethod
- def set_current_profile(profile_data: ProfileData, profile_name: str) -> ProfileData:
- if profile_name not in profile_data["profiles"]:
- raise ValueError(f"Profile '{profile_name}' does not exist")
- return ProfileData(
- current_profile=profile_name,
- profiles=dict(profile_data["profiles"]),
- global_config=dict(profile_data["global_config"]),
- )
+ def parse_toml_content(content: str) -> Dict[str, Any]:
+ data = ConfigurationManager.parse_toml_content_multi_profile(content)
+ return cast(Dict[str, Any], data["profiles"][DEFAULT_PROFILE_NAME])
diff --git a/py_modules/lsfg_vk/config_schema_generated.py b/py_modules/lsfg_vk/config_schema_generated.py
deleted file mode 100644
index 913609b..0000000
--- a/py_modules/lsfg_vk/config_schema_generated.py
+++ /dev/null
@@ -1,123 +0,0 @@
-"""
-Auto-generated configuration schema components from shared_config.py
-DO NOT EDIT THIS FILE MANUALLY - it will be overwritten on build
-"""
-
-from typing import TypedDict, Dict, Any, Union
-from enum import Enum
-import sys
-from pathlib import Path
-
-# Import shared configuration constants
-sys.path.insert(0, str(Path(__file__).parent.parent.parent))
-from shared_config import CONFIG_SCHEMA_DEF, ConfigFieldType
-
-# Field name constants for type-safe access
-DLL = "dll"
-NO_FP16 = "no_fp16"
-MULTIPLIER = "multiplier"
-FLOW_SCALE = "flow_scale"
-PERFORMANCE_MODE = "performance_mode"
-EXPERIMENTAL_PRESENT_MODE = "experimental_present_mode"
-DXVK_FRAME_RATE = "dxvk_frame_rate"
-ENABLE_WOW64 = "enable_wow64"
-DISABLE_STEAMDECK_MODE = "disable_steamdeck_mode"
-MANGOHUD_WORKAROUND = "mangohud_workaround"
-DISABLE_VKBASALT = "disable_vkbasalt"
-FORCE_ENABLE_VKBASALT = "force_enable_vkbasalt"
-ENABLE_WSI = "enable_wsi"
-ENABLE_ZINK = "enable_zink"
-
-
-class ConfigurationData(TypedDict):
- """Type-safe configuration data structure - AUTO-GENERATED"""
- dll: str
- no_fp16: bool
- multiplier: int
- flow_scale: float
- performance_mode: bool
- experimental_present_mode: str
- dxvk_frame_rate: int
- enable_wow64: bool
- disable_steamdeck_mode: bool
- mangohud_workaround: bool
- disable_vkbasalt: bool
- force_enable_vkbasalt: bool
- enable_wsi: bool
- enable_zink: bool
-
-
-def get_script_parsing_logic():
- """Return the script parsing logic as a callable"""
- def parse_script_values(lines):
- script_values = {}
- for line in lines:
- line = line.strip()
- if not line or line.startswith("#") or not line.startswith("export "):
- continue
- if "=" in line:
- export_line = line[len("export "):]
- key, value = export_line.split("=", 1)
- key = key.strip()
- value = value.strip()
-
- # Auto-generated parsing logic:
- if key == "DXVK_FRAME_RATE":
- try:
- script_values["dxvk_frame_rate"] = int(value)
- except ValueError:
- pass
- if key == "PROTON_USE_WOW64":
- script_values["enable_wow64"] = value == "1"
- if key == "SteamDeck":
- script_values["disable_steamdeck_mode"] = value == "0"
- if key == "MANGOHUD":
- script_values["mangohud_workaround"] = value == "1"
- if key == "DISABLE_VKBASALT":
- script_values["disable_vkbasalt"] = value == "1"
- if key == "ENABLE_VKBASALT":
- script_values["force_enable_vkbasalt"] = value == "1"
- if key == "ENABLE_GAMESCOPE_WSI":
- script_values["enable_wsi"] = value != "0"
- if key == "DXVK_HDR":
- script_values["enable_wsi"] = value != "0"
- if key == "__GLX_VENDOR_LIBRARY_NAME" and value == "mesa":
- script_values["enable_zink"] = True
- if key == "MESA_LOADER_DRIVER_OVERRIDE" and value == "zink":
- script_values["enable_zink"] = True
- if key == "GALLIUM_DRIVER" and value == "zink":
- script_values["enable_zink"] = True
-
- return script_values
- return parse_script_values
-
-
-def get_script_generation_logic():
- """Return the script generation logic as a callable"""
- def generate_script_lines(config):
- lines = []
- dxvk_frame_rate = config.get("dxvk_frame_rate", 0)
- if dxvk_frame_rate > 0:
- lines.append(f"export DXVK_FRAME_RATE={dxvk_frame_rate}")
- if config.get("enable_wow64", False):
- lines.append("export PROTON_USE_WOW64=1")
- if config.get("disable_steamdeck_mode", False):
- lines.append("export SteamDeck=0")
- if config.get("mangohud_workaround", False):
- lines.append("export MANGOHUD=1")
- if config.get("disable_vkbasalt", False):
- lines.append("export DISABLE_VKBASALT=1")
- if config.get("force_enable_vkbasalt", False):
- lines.append("export ENABLE_VKBASALT=1")
- if not config.get("enable_wsi", False):
- lines.append("export ENABLE_GAMESCOPE_WSI=0")
- lines.append("export DXVK_HDR=0")
- if config.get("enable_zink", False):
- lines.append("export __GLX_VENDOR_LIBRARY_NAME=mesa")
- lines.append("export MESA_LOADER_DRIVER_OVERRIDE=zink")
- lines.append("export GALLIUM_DRIVER=zink")
- return lines
- return generate_script_lines
-
-
-ALL_FIELDS = ['dll', 'no_fp16', 'multiplier', 'flow_scale', 'performance_mode', 'experimental_present_mode', 'dxvk_frame_rate', 'enable_wow64', 'disable_steamdeck_mode', 'mangohud_workaround', 'disable_vkbasalt', 'force_enable_vkbasalt', 'enable_wsi', 'enable_zink']
diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py
index 12710cc..2626a66 100644
--- a/py_modules/lsfg_vk/configuration.py
+++ b/py_modules/lsfg_vk/configuration.py
@@ -1,229 +1,134 @@
+import re
import shlex
+from typing import Any, Dict
from .base_service import BaseService
from .config_schema import ConfigurationManager, DEFAULT_PROFILE_NAME, ProfileData
-from .config_schema_generated import ConfigurationData, get_script_generation_logic
from .runtime_service import RuntimeService
-from .types import ConfigurationResponse, ProfileResponse, ProfilesResponse
class ConfigurationService(BaseService):
+ """Controller-facing adapter over upstream lsfg-vk profiles."""
+
def __init__(self, logger=None, runtime_service: RuntimeService = None):
super().__init__(logger)
self.runtime_service = runtime_service or RuntimeService(logger=self.log)
- def get_config(self) -> ConfigurationResponse:
+ def _default_data(self) -> ProfileData:
+ defaults = ConfigurationManager.validate_config({})
+ return {"current_profile": DEFAULT_PROFILE_NAME, "profiles": {DEFAULT_PROFILE_NAME: defaults}, "global_config": {"dll": "", "no_fp16": False}}
+
+ def _get_profile_data(self) -> ProfileData:
+ if not self.config_file_path.exists():
+ return self._default_data()
+ return ConfigurationManager.parse_toml_content_multi_profile(self.config_file_path.read_text(encoding="utf-8"))
+
+ def _save_profile_data(self, data: ProfileData) -> None:
+ content = ConfigurationManager.generate_toml_content_multi_profile(data)
+ self.runtime_service.validate_config_content(content)
+ self._write_file(self.config_file_path, content, 0o644)
+
+ @staticmethod
+ def _game_profile_name(appid: str) -> str:
+ if not re.fullmatch(r"[0-9]+", str(appid)):
+ raise ValueError("appid must be numeric")
+ return f"game-{appid}"
+
+ @staticmethod
+ def _public_config(config: Dict[str, Any]) -> Dict[str, Any]:
+ return ConfigurationManager.validate_config(config)
+
+ def get_config(self) -> Dict[str, Any]:
try:
- profile_data = self._get_profile_data()
- current_profile = profile_data["current_profile"]
- config = profile_data["profiles"].get(current_profile, dict(ConfigurationManager.get_defaults()))
- return self._success_response(ConfigurationResponse, config=config)
+ data = self._get_profile_data()
+ return self._success_response(dict, config=self._public_config(data["profiles"][DEFAULT_PROFILE_NAME]))
except Exception as error:
self.log.error(f"Error reading lsfg config: {error}")
- return self._error_response(ConfigurationResponse, str(error), config=None)
+ return self._error_response(dict, str(error), config=None)
- def update_config_from_dict(self, config: ConfigurationData) -> ConfigurationResponse:
+ def get_game_configs(self) -> Dict[str, Any]:
try:
- profile_data = self._get_profile_data()
- return self.update_profile_config(profile_data["current_profile"], config)
+ data = self._get_profile_data()
+ games = []
+ for name, raw in data["profiles"].items():
+ active_in = raw.get("active_in", [])
+ if len(active_in) != 1 or not str(active_in[0]).isdigit():
+ continue
+ games.append({"appid": str(active_in[0]), "profile": name, "config": self._public_config(raw)})
+ return self._success_response(dict, default=self._public_config(data["profiles"][DEFAULT_PROFILE_NAME]), games=games)
except Exception as error:
- self.log.error(f"Error updating lsfg config: {error}")
- return self._error_response(ConfigurationResponse, str(error), config=None)
+ self.log.error(f"Error reading game configs: {error}")
+ return self._error_response(dict, str(error), default=None, games=[])
- def update_lsfg_script(self, config: ConfigurationData) -> ConfigurationResponse:
+ def get_game_config(self, appid: str) -> Dict[str, Any]:
try:
- profile_data: ProfileData = {
- "current_profile": DEFAULT_PROFILE_NAME,
- "profiles": {DEFAULT_PROFILE_NAME: dict(config)},
- "global_config": {
- "dll": config.get("dll", ""),
- "no_fp16": config.get("no_fp16", False),
- },
- }
- return self.update_lsfg_script_from_profile_data(profile_data)
+ data = self._get_profile_data()
+ name = self._game_profile_name(appid)
+ profile = data["profiles"].get(name)
+ if profile is None:
+ profile = next((value for value in data["profiles"].values() if str(appid) in value.get("active_in", [])), None)
+ return self._success_response(dict, appid=str(appid), exists=profile is not None, config=self._public_config(profile or data["profiles"][DEFAULT_PROFILE_NAME]))
except Exception as error:
- return self._error_response(ConfigurationResponse, str(error), config=None)
-
- def _generate_script_content_for_profile(self, profile_data: ProfileData) -> str:
- current_profile = profile_data["current_profile"]
- config = dict(profile_data["profiles"].get(current_profile, ConfigurationManager.get_defaults()))
- config["dll"] = profile_data["global_config"].get("dll", config.get("dll", ""))
- config["no_fp16"] = profile_data["global_config"].get("no_fp16", config.get("no_fp16", False))
-
- lines = ["#!/bin/bash"]
- lines.extend(get_script_generation_logic()(config))
- lines.extend(
- [
- f"export LSFGVK_CONFIG={shlex.quote(str(self.config_file_path))}",
- f"export LSFGVK_PROFILE={shlex.quote(current_profile)}",
- 'exec "$@"',
- ]
- )
- return "\n".join(lines) + "\n"
-
- def _generate_script_content(self, config: ConfigurationData) -> str:
- profile_data: ProfileData = {
- "current_profile": DEFAULT_PROFILE_NAME,
- "profiles": {DEFAULT_PROFILE_NAME: dict(config)},
- "global_config": {
- "dll": config.get("dll", ""),
- "no_fp16": config.get("no_fp16", False),
- },
- }
- return self._generate_script_content_for_profile(profile_data)
+ return self._error_response(dict, str(error), appid=str(appid), exists=False, config=None)
- def _get_profile_data(self) -> ProfileData:
- if not self.config_file_path.exists():
- default = ConfigurationManager.get_defaults()
- return ProfileData(
- current_profile=DEFAULT_PROFILE_NAME,
- profiles={DEFAULT_PROFILE_NAME: dict(default)},
- global_config={
- "dll": default.get("dll", ""),
- "no_fp16": default.get("no_fp16", False),
- },
- )
-
- profile_data = ConfigurationManager.parse_toml_content_multi_profile(
- self.config_file_path.read_text(encoding="utf-8")
- )
- if self.lsfg_script_path.exists():
- script_content = self.lsfg_script_path.read_text(encoding="utf-8")
- selected = ConfigurationManager.parse_profile_selection(script_content)
- if selected in profile_data["profiles"]:
- profile_data["current_profile"] = selected
- current_profile = profile_data["current_profile"]
- profile_data["profiles"][current_profile] = ConfigurationManager.merge_config_with_script(
- profile_data["profiles"][current_profile],
- ConfigurationManager.parse_script_content(script_content),
- )
- return profile_data
-
- def _save_profile_data(self, profile_data: ProfileData) -> None:
- content = ConfigurationManager.generate_toml_content_multi_profile(profile_data)
- self.runtime_service.validate_config_content(content)
- self._write_file(
- self.config_file_path,
- content,
- 0o644,
- )
-
- def get_profiles(self) -> ProfilesResponse:
- try:
- profile_data = self._get_profile_data()
- return self._success_response(
- ProfilesResponse,
- "Profiles retrieved successfully",
- profiles=list(profile_data["profiles"]),
- current_profile=profile_data["current_profile"],
- )
- except Exception as error:
- return self._error_response(
- ProfilesResponse,
- str(error),
- profiles=None,
- current_profile=None,
- )
-
- def create_profile(self, profile_name: str, source_profile: str = None) -> ProfileResponse:
+ def update_game_config(self, appid: str, config: Dict[str, Any]) -> Dict[str, Any]:
try:
- profile_data = self._get_profile_data()
- new_profile_data = ConfigurationManager.create_profile(profile_data, profile_name, source_profile)
- self._save_profile_data(new_profile_data)
- normalized = ConfigurationManager.normalize_profile_name(profile_name)
- return self._success_response(
- ProfileResponse,
- f"Profile '{normalized}' created successfully",
- profile_name=normalized,
- )
+ data = self._get_profile_data()
+ name = self._game_profile_name(appid)
+ validated = self._public_config(config)
+ validated["active_in"] = [str(appid)]
+ data["profiles"][name] = validated
+ self._save_profile_data(data)
+ return self._success_response(dict, appid=str(appid), config=validated)
except Exception as error:
- return self._error_response(ProfileResponse, str(error), profile_name=None)
+ return self._error_response(dict, str(error), appid=str(appid), config=None)
- def delete_profile(self, profile_name: str) -> ProfileResponse:
+ def reset_game_config(self, appid: str) -> Dict[str, Any]:
try:
- profile_data = ConfigurationManager.delete_profile(self._get_profile_data(), profile_name)
- self._save_profile_data(profile_data)
- script_result = self.update_lsfg_script_from_profile_data(profile_data)
- if not script_result["success"]:
- raise OSError(script_result["error"])
- return self._success_response(
- ProfileResponse,
- f"Profile '{profile_name}' deleted successfully",
- profile_name=profile_name,
- )
+ data = self._get_profile_data()
+ name = self._game_profile_name(appid)
+ data["profiles"].pop(name, None)
+ for profile_name, profile in list(data["profiles"].items()):
+ if profile_name != DEFAULT_PROFILE_NAME and str(appid) in profile.get("active_in", []):
+ data["profiles"].pop(profile_name)
+ self._save_profile_data(data)
+ return self._success_response(dict, appid=str(appid), config=self._public_config(data["profiles"][DEFAULT_PROFILE_NAME]))
except Exception as error:
- return self._error_response(ProfileResponse, str(error), profile_name=None)
+ return self._error_response(dict, str(error), appid=str(appid), config=None)
- def rename_profile(self, old_name: str, new_name: str) -> ProfileResponse:
+ def reset_all_game_configs(self) -> Dict[str, Any]:
try:
- profile_data = ConfigurationManager.rename_profile(self._get_profile_data(), old_name, new_name)
- self._save_profile_data(profile_data)
- script_result = self.update_lsfg_script_from_profile_data(profile_data)
- if not script_result["success"]:
- raise OSError(script_result["error"])
- normalized = ConfigurationManager.normalize_profile_name(new_name)
- return self._success_response(
- ProfileResponse,
- f"Profile renamed to '{normalized}' successfully",
- profile_name=normalized,
- )
+ data = self._get_profile_data()
+ data["profiles"] = {DEFAULT_PROFILE_NAME: data["profiles"][DEFAULT_PROFILE_NAME]}
+ self._save_profile_data(data)
+ return self._success_response(dict, default=self._public_config(data["profiles"][DEFAULT_PROFILE_NAME]), games=[])
except Exception as error:
- return self._error_response(ProfileResponse, str(error), profile_name=None)
+ return self._error_response(dict, str(error), default=None, games=[])
- def set_current_profile(self, profile_name: str) -> ProfileResponse:
+ def update_config_from_dict(self, config: Dict[str, Any]) -> Dict[str, Any]:
try:
- profile_data = ConfigurationManager.set_current_profile(self._get_profile_data(), profile_name)
- script_result = self.update_lsfg_script_from_profile_data(profile_data)
- if not script_result["success"]:
- raise OSError(script_result["error"])
- return self._success_response(
- ProfileResponse,
- f"Current profile set to '{profile_name}' successfully",
- profile_name=profile_name,
- )
+ data = self._get_profile_data()
+ validated = self._public_config(config)
+ validated["active_in"] = []
+ data["profiles"][DEFAULT_PROFILE_NAME] = validated
+ data["global_config"] = {"dll": validated.get("dll", ""), "no_fp16": validated.get("no_fp16", False)}
+ self._save_profile_data(data)
+ return self._success_response(dict, config=validated)
except Exception as error:
- return self._error_response(ProfileResponse, str(error), profile_name=None)
+ return self._error_response(dict, str(error), config=None)
- def update_profile_config(self, profile_name: str, config: ConfigurationData) -> ConfigurationResponse:
- try:
- profile_data = self._get_profile_data()
- if profile_name not in profile_data["profiles"]:
- raise ValueError(f"Profile '{profile_name}' does not exist")
-
- validated = ConfigurationManager.validate_config(config)
- profile_data["profiles"][profile_name] = {
- **profile_data["profiles"][profile_name],
- **validated,
- }
- profile_data["global_config"]["dll"] = validated.get("dll", "")
- profile_data["global_config"]["no_fp16"] = validated.get("no_fp16", False)
- self._save_profile_data(profile_data)
-
- if profile_name == profile_data["current_profile"]:
- script_result = self.update_lsfg_script_from_profile_data(profile_data)
- if not script_result["success"]:
- raise OSError(script_result["error"])
-
- return self._success_response(
- ConfigurationResponse,
- f"Profile '{profile_name}' configuration updated successfully",
- config=validated,
- )
- except Exception as error:
- return self._error_response(ConfigurationResponse, str(error), config=None)
+ def update_lsfg_script(self, config: Dict[str, Any]) -> Dict[str, Any]:
+ return self.update_config_from_dict(config)
+
+ def _generate_script_content_for_profile(self, profile_data: ProfileData) -> str:
+ return "#!/bin/bash\n" f"export LSFGVK_CONFIG={shlex.quote(str(self.config_file_path))}\n" 'exec "$@"\n'
+
+ def _generate_script_content(self, config: Dict[str, Any]) -> str:
+ return self._generate_script_content_for_profile(self._default_data())
- def update_lsfg_script_from_profile_data(self, profile_data: ProfileData) -> ConfigurationResponse:
+ def update_lsfg_script_from_profile_data(self, profile_data: ProfileData) -> Dict[str, Any]:
try:
- script_content = self._generate_script_content_for_profile(profile_data)
- self._write_file(self.lsfg_script_path, script_content, 0o755)
- current_config = profile_data["profiles"].get(
- profile_data["current_profile"],
- dict(ConfigurationManager.get_defaults()),
- )
- return self._success_response(
- ConfigurationResponse,
- "Launch script updated successfully",
- config=current_config,
- )
+ self._write_file(self.lsfg_script_path, self._generate_script_content_for_profile(profile_data), 0o755)
+ return self._success_response(dict)
except Exception as error:
- return self._error_response(ConfigurationResponse, str(error), config=None)
+ return self._error_response(dict, str(error))
diff --git a/py_modules/lsfg_vk/installation.py b/py_modules/lsfg_vk/installation.py
index e979ae5..f7bfdaf 100644
--- a/py_modules/lsfg_vk/installation.py
+++ b/py_modules/lsfg_vk/installation.py
@@ -24,13 +24,20 @@ from .constants import (
UI_ICON_FILENAME,
)
from .runtime_service import RuntimeService
+from .steam_service import SteamService
from .types import InstallationCheckResponse, InstallationResponse, UninstallationResponse
class InstallationService(BaseService):
- def __init__(self, logger=None, runtime_service: RuntimeService = None):
+ def __init__(
+ self,
+ logger=None,
+ runtime_service: RuntimeService = None,
+ steam_service: SteamService = None,
+ ):
super().__init__(logger)
self.runtime_service = runtime_service or RuntimeService(logger=self.log)
+ self.steam_service = steam_service or SteamService(logger=self.log)
self.lib_file = self.local_lib_dir / LIB_FILENAME
self.lib_x86_file = self.local_lib_dir / LIB_X86_FILENAME
self.json_file = self.local_share_dir / JSON_FILENAME
@@ -143,33 +150,25 @@ class InstallationService(BaseService):
},
)
+ self._resolve_dll_path(profile_data)
defaults = dict(ConfigurationManager.get_defaults())
for profile_name, raw_profile in list(profile_data["profiles"].items()):
- validated = ConfigurationManager.validate_config({**defaults, **raw_profile})
- profile_data["profiles"][profile_name] = {**raw_profile, **validated}
-
- if self.lsfg_script_path.exists():
- script_content = self.lsfg_script_path.read_text(encoding="utf-8")
- selected = ConfigurationManager.parse_profile_selection(script_content)
- if selected in profile_data["profiles"]:
- profile_data["current_profile"] = selected
- current_profile = profile_data["current_profile"]
- profile_data["profiles"][current_profile] = ConfigurationManager.merge_config_with_script(
- profile_data["profiles"][current_profile],
- ConfigurationManager.parse_script_content(script_content),
+ profile_data["profiles"][profile_name] = ConfigurationManager.validate_config(
+ {**defaults, **raw_profile, **profile_data["global_config"]}
)
+ profile_data["current_profile"] = DEFAULT_PROFILE_NAME
+ return profile_data
- if profile_data["current_profile"] not in profile_data["profiles"]:
- profile_data["current_profile"] = (
- DEFAULT_PROFILE_NAME
- if DEFAULT_PROFILE_NAME in profile_data["profiles"]
- else next(iter(profile_data["profiles"]))
- )
+ def _resolve_dll_path(self, profile_data: ProfileData) -> bool:
+ current_path = str(profile_data["global_config"].get("dll") or "")
+ if current_path and Path(current_path).is_file():
+ return False
- for profile in profile_data["profiles"].values():
- profile["dll"] = profile_data["global_config"].get("dll", "")
- profile["no_fp16"] = profile_data["global_config"].get("no_fp16", False)
- return profile_data
+ dll_path = self.steam_service.find_lsfg_vk_dll()
+ if dll_path and current_path != dll_path:
+ profile_data["global_config"]["dll"] = dll_path
+ return True
+ return False
def _create_lsfg_launch_script(self, profile_data: ProfileData) -> None:
from .configuration import ConfigurationService
@@ -202,6 +201,13 @@ class InstallationService(BaseService):
if legacy_layer or legacy_config:
return True
try:
+ if self.config_file_path.exists():
+ data = ConfigurationManager.parse_toml_content_multi_profile(
+ self.config_file_path.read_text(encoding="utf-8")
+ )
+ configured = str(data["global_config"].get("dll") or "")
+ if (not configured or not Path(configured).is_file()) and self.steam_service.find_lsfg_vk_dll():
+ return True
return not self.runtime_service.is_healthy()
except Exception:
return True
diff --git a/py_modules/lsfg_vk/plugin.py b/py_modules/lsfg_vk/plugin.py
index f764086..3b9a97f 100644
--- a/py_modules/lsfg_vk/plugin.py
+++ b/py_modules/lsfg_vk/plugin.py
@@ -31,10 +31,13 @@ class Plugin:
def __init__(self):
"""Initialize the plugin with all necessary services"""
self.runtime_service = RuntimeService()
- self.installation_service = InstallationService(runtime_service=self.runtime_service)
+ self.steam_service = SteamService()
+ self.installation_service = InstallationService(
+ runtime_service=self.runtime_service,
+ steam_service=self.steam_service,
+ )
self.configuration_service = ConfigurationService(runtime_service=self.runtime_service)
self.flatpak_service = FlatpakService()
- self.steam_service = SteamService()
async def install_lsfg_vk(self) -> Dict[str, Any]:
"""Install the bundled lsfg-vk runtime to ~/.local
@@ -74,33 +77,11 @@ class Plugin:
Returns:
Dict with field names, types, defaults, and profile information
"""
- try:
- profiles_response = self.configuration_service.get_profiles()
-
- schema_data = {
- "field_names": ConfigurationManager.get_field_names(),
- "field_types": {name: field_type.value for name, field_type in ConfigurationManager.get_field_types().items()},
- "defaults": ConfigurationManager.get_defaults()
- }
-
- if profiles_response.get("success"):
- schema_data["profiles"] = profiles_response.get("profiles", [])
- schema_data["current_profile"] = profiles_response.get("current_profile")
- else:
- schema_data["profiles"] = ["decky-lsfg-vk"]
- schema_data["current_profile"] = "decky-lsfg-vk"
-
- return schema_data
-
- except (ValueError, KeyError, AttributeError) as e:
- self.configuration_service.log.warning(f"Failed to get full schema, using fallback: {e}")
- return {
- "field_names": ConfigurationManager.get_field_names(),
- "field_types": {name: field_type.value for name, field_type in ConfigurationManager.get_field_types().items()},
- "defaults": ConfigurationManager.get_defaults(),
- "profiles": ["decky-lsfg-vk"],
- "current_profile": "decky-lsfg-vk"
- }
+ return {
+ "field_names": ConfigurationManager.get_field_names(),
+ "field_types": ConfigurationManager.get_field_types(),
+ "defaults": ConfigurationManager.get_defaults(),
+ }
async def update_lsfg_config(self, config: Dict[str, Any]) -> Dict[str, Any]:
"""Update lsfg TOML configuration using object-based API (single source of truth)
@@ -111,19 +92,35 @@ class Plugin:
Returns:
ConfigurationResponse dict with success status
"""
- validated_config = ConfigurationManager.validate_config(config)
-
- return self.configuration_service.update_config_from_dict(validated_config)
+ return self.configuration_service.update_config_from_dict(config)
+
+ async def get_game_configs(self) -> Dict[str, Any]:
+ return self.configuration_service.get_game_configs()
+
+ async def get_installed_games(self) -> Dict[str, Any]:
+ return self.steam_service.get_installed_games()
- async def get_profiles(self) -> Dict[str, Any]:
+ async def get_game_config(self, appid: str) -> Dict[str, Any]:
+ return self.configuration_service.get_game_config(appid)
+
+ async def update_game_config(self, appid: str, config: Dict[str, Any]) -> Dict[str, Any]:
+ return self.configuration_service.update_game_config(appid, config)
+
+ async def reset_game_config(self, appid: str) -> Dict[str, Any]:
+ return self.configuration_service.reset_game_config(appid)
+
+ async def reset_all_game_configs(self) -> Dict[str, Any]:
+ return self.configuration_service.reset_all_game_configs()
+
+ async def _legacy_get_profiles(self) -> Dict[str, Any]:
"""Get list of all profiles and current profile
Returns:
ProfilesResponse dict with profile list and current profile
"""
- return self.configuration_service.get_profiles()
+ return self.configuration_service.get_game_configs()
- async def create_profile(self, profile_name: str, source_profile: str = None) -> Dict[str, Any]:
+ async def _legacy_create_profile(self, profile_name: str, source_profile: str = None) -> Dict[str, Any]:
"""Create a new profile
Args:
@@ -133,9 +130,9 @@ class Plugin:
Returns:
ProfileResponse dict with success status
"""
- return self.configuration_service.create_profile(profile_name, source_profile)
+ return {"success": False, "error": "Named profiles were replaced by per-game AppID profiles"}
- async def delete_profile(self, profile_name: str) -> Dict[str, Any]:
+ async def _legacy_delete_profile(self, profile_name: str) -> Dict[str, Any]:
"""Delete a profile
Args:
@@ -144,9 +141,9 @@ class Plugin:
Returns:
ProfileResponse dict with success status
"""
- return self.configuration_service.delete_profile(profile_name)
+ return {"success": False, "error": "Named profiles were replaced by per-game AppID profiles"}
- async def rename_profile(self, old_name: str, new_name: str) -> Dict[str, Any]:
+ async def _legacy_rename_profile(self, old_name: str, new_name: str) -> Dict[str, Any]:
"""Rename a profile
Args:
@@ -156,9 +153,9 @@ class Plugin:
Returns:
ProfileResponse dict with success status
"""
- return self.configuration_service.rename_profile(old_name, new_name)
+ return {"success": False, "error": "Named profiles were replaced by per-game AppID profiles"}
- async def set_current_profile(self, profile_name: str) -> Dict[str, Any]:
+ async def _legacy_set_current_profile(self, profile_name: str) -> Dict[str, Any]:
"""Set the current active profile
Args:
@@ -167,9 +164,9 @@ class Plugin:
Returns:
ProfileResponse dict with success status
"""
- return self.configuration_service.set_current_profile(profile_name)
+ return {"success": False, "error": "There is no globally selected profile"}
- async def update_profile_config(self, profile_name: str, config: Dict[str, Any]) -> Dict[str, Any]:
+ async def _legacy_update_profile_config(self, profile_name: str, config: Dict[str, Any]) -> Dict[str, Any]:
"""Update configuration for a specific profile
Args:
@@ -179,9 +176,7 @@ class Plugin:
Returns:
ConfigurationResponse dict with success status
"""
- validated_config = ConfigurationManager.validate_config(config)
-
- return self.configuration_service.update_profile_config(profile_name, validated_config)
+ return {"success": False, "error": "Use update_game_config with a Steam AppID"}
async def get_launch_option(self) -> Dict[str, Any]:
"""Get the launch option that users need to set for their games
@@ -192,7 +187,7 @@ class Plugin:
return {
"launch_option": "~/lsfg %command%",
"instructions": "Add this to your game's launch options in Steam Properties",
- "explanation": "The lsfg script is created during installation and sets up the environment for the plugin"
+ "explanation": "The lsfg script points games at the upstream configuration; profiles are selected by Steam AppID"
}
async def get_config_file_content(self) -> Dict[str, Any]:
diff --git a/py_modules/lsfg_vk/runtime_service.py b/py_modules/lsfg_vk/runtime_service.py
index a61220e..8785522 100644
--- a/py_modules/lsfg_vk/runtime_service.py
+++ b/py_modules/lsfg_vk/runtime_service.py
@@ -24,7 +24,7 @@ class RuntimeService(BaseService):
HOME=str(self.user_home),
XDG_CONFIG_HOME=str(self.user_home / ".config"),
)
- for name in ("LSFGVK_CONFIG", "LSFGVK_PROFILE", "LSFGVK_ENV"):
+ for name in ("LSFGVK_CONFIG", "LSFGVK_ENV"):
environment.pop(name, None)
return environment
diff --git a/py_modules/lsfg_vk/steam_service.py b/py_modules/lsfg_vk/steam_service.py
index 867a135..58e0a20 100644
--- a/py_modules/lsfg_vk/steam_service.py
+++ b/py_modules/lsfg_vk/steam_service.py
@@ -128,6 +128,16 @@ class SteamService(BaseService):
),
}
+ def find_lsfg_vk_dll(self) -> Optional[str]:
+ """Find the branch-specific upstream DLL in any Steam library."""
+ if self.get_branch_status().get("needs_switch"):
+ return None
+ for library_root in self._steam_library_roots():
+ dll_path = library_root / "steamapps/common/Lossless Scaling/lsfg-vk.dll"
+ if dll_path.is_file():
+ return str(dll_path)
+ return None
+
def get_branch_status(self) -> Dict[str, object]:
try:
manifest_path = self._manifest_path()
@@ -165,3 +175,23 @@ class SteamService(BaseService):
needs_switch=False,
restart_required=False,
)
+
+ def get_installed_games(self) -> Dict[str, object]:
+ """Return installed Steam app IDs and names for the Game Mode selector."""
+ try:
+ games = {}
+ for library_root in self._steam_library_roots():
+ for manifest in (library_root / "steamapps").glob("appmanifest_*.acf"):
+ match = re.fullmatch(r"appmanifest_(\d+)\.acf", manifest.name)
+ if not match:
+ continue
+ try:
+ content = manifest.read_text(encoding="utf-8")
+ except OSError:
+ continue
+ appid = match.group(1)
+ name = self._section_value(content, "AppState", "name") or f"App {appid}"
+ games[appid] = name
+ return self._success_response(dict, games=[{"appid": appid, "name": name} for appid, name in sorted(games.items(), key=lambda item: item[1].lower())])
+ except Exception as error:
+ return self._error_response(dict, str(error), games=[])
diff --git a/py_modules/lsfg_vk/types.py b/py_modules/lsfg_vk/types.py
index 2c56a15..ef6bab7 100644
--- a/py_modules/lsfg_vk/types.py
+++ b/py_modules/lsfg_vk/types.py
@@ -68,15 +68,16 @@ class ProfileConfig(TypedDict):
class ProfilesResponse(BaseResponse):
- """Response for profile operations"""
- profiles: Optional[List[str]]
- current_profile: Optional[str]
+ """Response for per-game upstream profiles"""
+ default: Optional[ConfigurationData]
+ games: Optional[List[Dict[str, Any]]]
message: Optional[str]
error: Optional[str]
class ProfileResponse(BaseResponse):
- """Response for single profile operations"""
- profile_name: Optional[str]
+ """Response for a per-game upstream profile"""
+ appid: Optional[str]
+ config: Optional[ConfigurationData]
message: Optional[str]
error: Optional[str]