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

@ -1,6 +1,6 @@
# Maintainer: Cosmo
pkgname=xivlauncher-wrapper
pkgver=0.1.0
pkgver=0.3.0
pkgrel=1
pkgdesc="Wrapper for XIVLauncher with OTP injection"
arch=('any')

View file

@ -9,6 +9,7 @@ This is a wrapper script for Linux that launches `xivlauncher-core` (Native or F
- **OTP Injection**: Generates TOTP codes and sends them to the launcher's internal server.
- **URL Support**: Accepts standard Base32 secrets OR full `otpauth://` URLs (e.g. from QR codes).
- **Auto-Configuration**: Prompts to fix `launcher.ini` settings if they are incorrect.
- **Performance Optimization**: Automatically detects and integrates with `gamemoderun` or `game-performance` to optimize your game instance.
## Installation (Steam Deck / Linux Desktop)
@ -42,8 +43,10 @@ The easiest way to install is using the provided installer script. This script w
cp config.example.json ~/.config/xivlauncher-wrapper/config.json
nano ~/.config/xivlauncher-wrapper/config.json
```
* `secret`: Enter your TOTP secret key or `otpauth://` URL.
* `secret`: Enter your TOTP secret key or `otpauth://` URL (optional, defaults to secure system keyring).
* `launcher_cmd`: (Optional) The command to launch XIVLauncher. If omitted, the wrapper will auto-detect it.
* `use_gamemode`: (Optional) Set to `true` to launch using a game performance wrapper.
* `gamemode_cmd`: (Optional) The specific game performance utility to use (e.g., `"gamemoderun"` or `"game-performance"`).
2. **Make Executable:**
```bash

View file

@ -1,3 +1,6 @@
{
"launcher_cmd": "flatpak run dev.goats.xivlauncher"
"launcher_cmd": "flatpak run dev.goats.xivlauncher",
"secret": "",
"use_gamemode": false,
"gamemode_cmd": "gamemoderun"
}

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'