Setting up camera capture on locked phone
I have tasker pro and after a number of attempts I was unable to get my phone to capture a photograph remotely through an SMS. I have given tasker required permissions through:
adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
But it seems like it just doesn’t work, as mentioned here: Locked screen photo help : tasker
So I really need this functionality and decided to go the tasker
+ termux
route.
Installing dependencies
- First you need Termux:Tasker which will bridge tasker and termux. You’ll need to grant
tasker
permissions to usetermux
, you’ll find this intasker
’s additional permissions section. - After that you’ll need to use the program called
termux-camera-photo
which requirestermux
to have access to your phone api. For this you’ll have to install Termux:API(This will grant you the required permissions) once done you’ll have to installtermux-api
insidetermux
which will have you installedtermux-camera-photo
and other programs which will use theTermux:API
. - At this point you’re all set to take photos using
termux
. Seetermux-camea-photo -h
Setting up storage
- But by default
termux
does not have shared storage on. What I intended to do is take photograph and upload it to google drive, this requirestermux
to have shared storage access so that it can store the photo. See Internal and external storage - Termux Wiki. You simply have to runtermux-setup-storage
and you’ll be good to go.
Execution from tasker to tmux
- Now I need to setup
tasker
to usetermux
to capture the photo. This requires setting theallow-external-apps
totrue
in~/.termux/termux.properties
. (Basically uncommenting a line). I had issues with this approach - The approach I used is just creating bash scripts inside
~/.termux/tasker
and using them from thetermux
plugin insidetasker
. Works great :)