From 320d0122004b1d0f3c30ea80160126450d5b8c03 Mon Sep 17 00:00:00 2001 From: User Date: Sun, 1 Feb 2026 11:27:22 +0100 Subject: [PATCH] fix: use termux-battery-status directly instead of which Co-Authored-By: Claude Opus 4.5 --- src/rf_mapper/termux.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/rf_mapper/termux.py b/src/rf_mapper/termux.py index 3ce68ca..bb9ce56 100644 --- a/src/rf_mapper/termux.py +++ b/src/rf_mapper/termux.py @@ -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: