feat: add xivlauncher optdepend and implement multi-provider fallback logic for OTP dialogs

This commit is contained in:
CPTN Cosmo 2026-04-18 15:34:45 +02:00
parent 6d19fb9c17
commit 940217d95d
2 changed files with 30 additions and 24 deletions

View file

@ -7,7 +7,7 @@ arch=('any')
url="https://github.com/goatcorp/XIVLauncher.Core" url="https://github.com/goatcorp/XIVLauncher.Core"
license=('MIT') license=('MIT')
depends=('python') depends=('python')
optdepends=() optdepends=('xivlauncher')
makedepends=('git') makedepends=('git')
source=("xivlauncher-wrapper.desktop" source=("xivlauncher-wrapper.desktop"
"xivlauncher-wrapper.png" "xivlauncher-wrapper.png"

View file

@ -28,29 +28,35 @@ def prompt_gui_secret():
"""Prompts for the OTP secret using a DE-appropriate GUI dialog (kdialog or zenity).""" """Prompts for the OTP secret using a DE-appropriate GUI dialog (kdialog or zenity)."""
desktop = os.environ.get('XDG_CURRENT_DESKTOP', '').lower() desktop = os.environ.get('XDG_CURRENT_DESKTOP', '').lower()
# Check for KDE dialogs = []
if 'kde' in desktop and shutil.which('kdialog'): if 'kde' in desktop and shutil.which('kdialog'):
try: dialogs.append('kdialog')
result = subprocess.run( if shutil.which('zenity'): dialogs.append('zenity')
['kdialog', '--password', 'Please enter your XIVLauncher TOTP Secret (base32) or otpauth:// URL:'], else:
capture_output=True, text=True if shutil.which('zenity'): dialogs.append('zenity')
) if shutil.which('kdialog'): dialogs.append('kdialog')
if result.returncode == 0:
return result.stdout.strip()
except Exception as e:
print(f"Warning: kdialog failed: {e}")
# Fallback to Zenity for GNOME/others for dialog in dialogs:
elif shutil.which('zenity'): if dialog == 'kdialog':
try: try:
result = subprocess.run( result = subprocess.run(
['zenity', '--password', '--title=XIVLauncher Wrapper', '--text=Please enter your TOTP Secret (base32) or otpauth:// URL:'], ['kdialog', '--password', 'Please enter your XIVLauncher TOTP Secret (base32) or otpauth:// URL:'],
capture_output=True, text=True capture_output=True, text=True
) )
if result.returncode == 0: if result.returncode == 0:
return result.stdout.strip() return result.stdout.strip()
except Exception as e: except Exception as e:
print(f"Warning: zenity failed: {e}") print(f"Warning: kdialog failed: {e}")
elif dialog == 'zenity':
try:
result = subprocess.run(
['zenity', '--password', '--title=XIVLauncher Wrapper', '--text=Please enter your TOTP Secret (base32) or otpauth:// URL:'],
capture_output=True, text=True
)
if result.returncode == 0:
return result.stdout.strip()
except Exception as e:
print(f"Warning: zenity failed: {e}")
return None return None