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"
license=('MIT')
depends=('python')
optdepends=()
optdepends=('xivlauncher')
makedepends=('git')
source=("xivlauncher-wrapper.desktop"
"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)."""
desktop = os.environ.get('XDG_CURRENT_DESKTOP', '').lower()
# Check for KDE
dialogs = []
if 'kde' in desktop and shutil.which('kdialog'):
try:
result = subprocess.run(
['kdialog', '--password', 'Please enter your XIVLauncher 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: kdialog failed: {e}")
dialogs.append('kdialog')
if shutil.which('zenity'): dialogs.append('zenity')
else:
if shutil.which('zenity'): dialogs.append('zenity')
if shutil.which('kdialog'): dialogs.append('kdialog')
# Fallback to Zenity for GNOME/others
elif shutil.which('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}")
for dialog in dialogs:
if dialog == 'kdialog':
try:
result = subprocess.run(
['kdialog', '--password', 'Please enter your XIVLauncher 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: 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