diff --git a/s.py b/s.py index 137b3de..44b304c 100644 --- a/s.py +++ b/s.py @@ -8,6 +8,7 @@ import json is_termux = os.environ.get('TERMUX_APP__PACKAGE_NAME') or os.environ.get('TERMUX_APK_RELEASE') +termux_api = False if is_termux: logger.info('Termux detected, checking permissions...') logger.info('Prevent killing termux by android, getting wakelock...') @@ -39,6 +40,11 @@ if is_termux: default_directory = '/sdcard/ub4tg' os.system(f'mkdir -p {default_directory}') default_config_file_path = f'{default_directory}/config.json' + termux_api = os.system('termux_api_start') == 0 + if termux_api: + logger.success('termux API works') + else: + logger.warning('termux API not installed or broken') if not os.path.exists(default_config_file_path): logger.info('config not found, first launch setup...') api_id = int(input('enter api_id from https://my.telegram.org/ : ')) diff --git a/src/updatenotif.py b/src/updatenotif.py index c96f2f0..36d3d55 100644 --- a/src/updatenotif.py +++ b/src/updatenotif.py @@ -1,3 +1,4 @@ +from s import termux_api from loguru import logger import os import asyncio @@ -8,7 +9,6 @@ async def git_notifications_update(): cwd = os.getcwd() os.chdir(cwd) while True: - termux_api = os.system('termux-api-start') if termux_api == 0: logger.info('Checking for updates...') fetching_git = os.system('git fetch')