File: android-deltas-sync/_etc/termux-widget-shims/initial-copy.py
#!/data/data/com.termux/files/usr/bin/python3 #!/usr/bin/env python3 # fails in widget, termux-exec or not """ ======================================================================== Initial copy: a simple Python 'shim' script for Termux:Widget. Run by home-screen widget taps, this starts another Python script located outside the widget's shortcuts folder, and named by the "runee" setting below. Change this if needed for your install path. The started script doesn't need the absolute '#!' line above, and can be in shared storage, which doesn't do executable permissions. This also keeps the console open without the ForceKeyToClose config. For convenience, this acquires/releases an Android partial wakelock, so the "runee" script keeps running even if the screen blanks due to either timeout or a power-button press. As of [1.2], wakelock calls are "&" backgrounded to avoid pauses here, and can be disabled by setting auto_wakelock below, per ../../_README.html#shimschanges12. Copy this to your app-private ~/.shortcuts folder in Termux with a "cp" command or _install-shims.sh, and run by a widget tap on your home screen. See ./_README.txt for an example of the required copy command and additional details, and ../screenshots for widget demos. See ../../_README.html for license, attribution, version, and docs. ======================================================================== """ # EDIT if needed runee = '/sdcard/Download/android-deltas-sync/initial-copy-part2-phone.py' import sys, os trace = lambda *args: None auto_wakelock = True if auto_wakelock: trace('(acquiring wakelock)') os.system('termux-wake-lock &') # keep cpu running (but don't wait) os.system(sys.executable + ' ' + runee) # run package's main script if auto_wakelock: trace('(releasing wakelock)') os.system('termux-wake-unlock &') # release wake lock (but don't wait) input('Bye (press enter)') # keep console open till enter/return