feat: add xivlauncher optdepend and implement multi-provider fallback logic for OTP dialogs
This commit is contained in:
parent
6d19fb9c17
commit
940217d95d
2 changed files with 30 additions and 24 deletions
2
PKGBUILD
2
PKGBUILD
|
|
@ -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"
|
||||
|
|
|
|||
52
wrapper.py
52
wrapper.py
|
|
@ -28,30 +28,36 @@ 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}")
|
||||
|
||||
# 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}")
|
||||
|
||||
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')
|
||||
|
||||
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
|
||||
|
||||
def parse_secret(secret_input):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue