feat: add support for Flatpak launcher.ini paths and introduce is_interactive helper to handle non-interactive environments correctly
This commit is contained in:
parent
5ea9f38a12
commit
7f4654f96e
1 changed files with 19 additions and 8 deletions
27
wrapper.py
27
wrapper.py
|
|
@ -138,18 +138,25 @@ def send_otp(secret):
|
|||
print("Timed out waiting for XIVLauncher OTP prompt.")
|
||||
|
||||
def check_and_update_launcher_ini():
|
||||
"""Checks ~/.xlcore/launcher.ini for IsOtpServer setting.
|
||||
"""Checks launcher.ini for IsOtpServer setting.
|
||||
|
||||
If file is missing: prompts user to enable it manually in launcher.
|
||||
If file exists but setting is off: prompts user to auto-enable it.
|
||||
"""
|
||||
ini_path = os.path.expanduser("~/.xlcore/launcher.ini")
|
||||
native_ini = os.path.expanduser("~/.xlcore/launcher.ini")
|
||||
flatpak_ini = os.path.expanduser("~/.var/app/dev.goats.xivlauncher/data/xivlauncher/launcher.ini")
|
||||
|
||||
if not os.path.exists(ini_path):
|
||||
print(f"\nConfiguration Check: '{ini_path}' not found.")
|
||||
ini_path = None
|
||||
if os.path.exists(native_ini):
|
||||
ini_path = native_ini
|
||||
elif os.path.exists(flatpak_ini):
|
||||
ini_path = flatpak_ini
|
||||
|
||||
if not ini_path:
|
||||
print(f"\nConfiguration Check: Could not find launcher.ini (checked ~/.xlcore and flatpak paths).")
|
||||
print("Please open XIVLauncher, go to Settings, and enable 'Start internal OTP server'.")
|
||||
print("This is required for the wrapper to function.")
|
||||
if sys.stdin.isatty():
|
||||
if is_interactive():
|
||||
try:
|
||||
input("Press Enter to continue once you have done this (or to try anyway)...")
|
||||
except EOFError:
|
||||
|
|
@ -179,7 +186,7 @@ def check_and_update_launcher_ini():
|
|||
print("XIVLauncher requires 'IsOtpServer' to be enabled to accept OTP codes from this wrapper.")
|
||||
|
||||
choice = 'n'
|
||||
if sys.stdin.isatty():
|
||||
if is_interactive():
|
||||
try:
|
||||
choice = input("Enable 'IsOtpServer' now? [Y/n]: ").strip().lower()
|
||||
except EOFError:
|
||||
|
|
@ -247,6 +254,10 @@ def is_steam_env():
|
|||
return True
|
||||
return False
|
||||
|
||||
def is_interactive():
|
||||
"""Checks if we are in a truly interactive terminal session (not running under Steam)."""
|
||||
return sys.stdin.isatty() and not is_steam_env()
|
||||
|
||||
def get_secret(config, config_path, allow_prompt=True):
|
||||
"""
|
||||
Retrieves the OTP secret in the following priority:
|
||||
|
|
@ -306,7 +317,7 @@ def get_secret(config, config_path, allow_prompt=True):
|
|||
|
||||
if not secret_input:
|
||||
print("GUI prompt unavailable or cancelled. Falling back to CLI.")
|
||||
if not sys.stdin.isatty():
|
||||
if not is_interactive():
|
||||
print("Error: No interactive terminal available and GUI prompt failed. Cannot prompt for secret.")
|
||||
return None
|
||||
|
||||
|
|
@ -482,7 +493,7 @@ def main():
|
|||
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:
|
||||
if sys.stdin.isatty():
|
||||
if is_interactive():
|
||||
choice = input(f"Enable {gamemode_cmd}? [Y/n]: ").strip().lower()
|
||||
else:
|
||||
choice = 'y' # auto-enable if not interactive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue