fix: use termux-battery-status directly instead of which
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,19 +33,6 @@ def is_termux() -> bool:
|
||||
|
||||
def check_termux_api_installed() -> tuple[bool, str]:
|
||||
"""Check if termux-api package and Termux:API app are installed."""
|
||||
# Check for termux-api command
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["which", "termux-location"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
if result.returncode != 0:
|
||||
return False, "termux-api package not installed. Run: pkg install termux-api"
|
||||
except (subprocess.TimeoutExpired, FileNotFoundError):
|
||||
return False, "termux-api package not installed. Run: pkg install termux-api"
|
||||
|
||||
# Test if Termux:API app is working (quick test with battery status)
|
||||
try:
|
||||
result = subprocess.run(
|
||||
@@ -54,8 +41,13 @@ def check_termux_api_installed() -> tuple[bool, str]:
|
||||
text=True,
|
||||
timeout=10
|
||||
)
|
||||
if result.returncode != 0 or "error" in result.stderr.lower():
|
||||
if result.returncode != 0:
|
||||
return False, "Termux:API app not installed or not granted permissions"
|
||||
if "error" in result.stderr.lower():
|
||||
return False, "Termux:API app error. Reinstall from F-Droid"
|
||||
# Verify we got valid JSON output
|
||||
if not result.stdout.strip().startswith("{"):
|
||||
return False, "Termux:API app not responding correctly"
|
||||
except subprocess.TimeoutExpired:
|
||||
return False, "Termux:API app not responding. Install from F-Droid and grant permissions"
|
||||
except FileNotFoundError:
|
||||
|
||||
Reference in New Issue
Block a user