[REQUIRES ROOT]
Hi I came up with a way to integrate the switch with tasker, it’s a little long winded but its still working really well for me:
1: Set the switch to use Fairphone moments in settings
2: Disable the Fairphone moments app, this is needed or it will do your tasker action and open the Fairphone moments app which isn’t very helpful
3: Create a file named switchlisten.sh, I placed it in /data/local/tmp but other locations should work fine. Contents of the file:
#!/system/bin/sh
getevent -l /dev/input/event0 | while read -r line; do
if echo “$line” | grep -q “SW_PEN_INSERTED.*00000001”; then
am broadcast -a com.odgebodge.switch_up
elif echo “$line” | grep -q “SW_PEN_INSERTED.*00000000”; then
am broadcast -a com.odgebodge.switch_down
fi
done
This will listen for the switch’s events (for some reason it’s the pen events, not sure why) you can also change “com.odgebodge” to whatever you want, just make sure it matches in step 5.
4: Set this script to run on boot in tasker, your action should be a run shell action with the following command: '“sh /data/local/tmp/switchlisten.sh” (change this to the path of your script). this MUST be set to use root.
5: create a tasker profile for the up and down action, the profile should be an intent received (in event → search for intent received) with the action set to com.odgebodge.switch_up for up, and com.odgebodge.switch_down for down.
6: reboot your phone to set the script going
7: you can now set the intent received profiles to whatever task you want, in my case I’m using it to enable and disable the mic and cameras
The only problem I can find with this solution is that tasker won’t be able to run other shell commands, but if you aren’t doing that or can set it running using something else then that is fine.
good luck
please let me know how it goes if you try it and if you need any more info