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"
|
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"
|
||||||
|
|
|
||||||
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)."""
|
"""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()
|
for dialog in dialogs:
|
||||||
except Exception as e:
|
if dialog == 'kdialog':
|
||||||
print(f"Warning: kdialog failed: {e}")
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
# Fallback to Zenity for GNOME/others
|
['kdialog', '--password', 'Please enter your XIVLauncher TOTP Secret (base32) or otpauth:// URL:'],
|
||||||
elif shutil.which('zenity'):
|
capture_output=True, text=True
|
||||||
try:
|
)
|
||||||
result = subprocess.run(
|
if result.returncode == 0:
|
||||||
['zenity', '--password', '--title=XIVLauncher Wrapper', '--text=Please enter your TOTP Secret (base32) or otpauth:// URL:'],
|
return result.stdout.strip()
|
||||||
capture_output=True, text=True
|
except Exception as e:
|
||||||
)
|
print(f"Warning: kdialog failed: {e}")
|
||||||
if result.returncode == 0:
|
elif dialog == 'zenity':
|
||||||
return result.stdout.strip()
|
try:
|
||||||
except Exception as e:
|
result = subprocess.run(
|
||||||
print(f"Warning: zenity failed: {e}")
|
['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
|
||||||
|
|
||||||
def parse_secret(secret_input):
|
def parse_secret(secret_input):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue