feat: Add auto-detection and integration for game performance wrappers like gamemoderun and game-performance.

This commit is contained in:
CPTN Cosmo 2026-03-26 21:29:07 +01:00
parent 95ec73df5c
commit 72c301be78
4 changed files with 45 additions and 3 deletions

View file

@ -355,6 +355,30 @@ def main():
config['launcher_cmd'] = cmd
config_dirty = True
# 2.5 Auto-detect gamemode/game-performance
if "use_gamemode" not in config:
gamemode_cmd = None
if shutil.which("game-performance"):
gamemode_cmd = "game-performance"
elif shutil.which("gamemoderun"):
gamemode_cmd = "gamemoderun"
if gamemode_cmd:
print(f"\n'{gamemode_cmd}' was detected on your system.")
print("Would you like to enable it for XIVLauncher? This can improve game performance.")
try:
choice = input(f"Enable {gamemode_cmd}? [Y/n]: ").strip().lower()
except (EOFError, KeyboardInterrupt):
choice = 'n'
print("\nPrompt interrupted, defaulting to No.")
if choice in ('', 'y', 'yes'):
config["use_gamemode"] = True
config["gamemode_cmd"] = gamemode_cmd
else:
config["use_gamemode"] = False
config_dirty = True
# Save config if updated (e.g. launcher_cmd detected)
if config_dirty:
try:
@ -384,6 +408,18 @@ def main():
import shlex
args = shlex.split(cmd)
# Prepend gamemode wrapper if enabled
if config.get("use_gamemode"):
g_cmd = config.get("gamemode_cmd")
if not g_cmd:
if shutil.which("game-performance"):
g_cmd = "game-performance"
elif shutil.which("gamemoderun"):
g_cmd = "gamemoderun"
if g_cmd and shutil.which(g_cmd):
args.insert(0, g_cmd)
print(f"Using game performance wrapper: {g_cmd}")
# Inject XL_SECRET_PROVIDER=file environment variable
env = os.environ.copy()
env['XL_SECRET_PROVIDER'] = 'file'