Post your questions and help other users.
Moderator: Martin
-
srichter
- Posts: 3
- Joined: 09 Jan 2018 16:32
Post
by srichter » 11 Jan 2018 00:27
Desmanto wrote:srichter wrote:
Are there any plans to add this functionality for rooted users? I would love to be able to monitor the file /sys/class/switch/tri-state-key as it will allow me to create flows to interact with the alert slider on my OnePlus 3T
Thanks
The tri-state-key is to check the interruptions mode right? If yes, there is trigger Interruptions Mode, which you can use to do something based on the mode. There is also action Set Interruptions mode.
I don't know how file/folder listening normally works. Probably it is done via media storage database, which already monitor all file changes. But for any folder outside of user accessible ones, we have to use root command. It is possible to loop and cat the content of that file. But it will definitely kill your battery, since the flow is running all the time.
Other alternative (if interruptions mode doesn't work) is to create your own widget for slider. When you change the mode in this widget slider, use root command to change the tri-state-key to make it sync.
tri-state-key gives a raw reading of the current position of the alert slider. Right now I use the interruptions mode trigger as a half-baked solution for detecting the slider events, but they'll trigger if the mode changes for other reasons besides the slider as well. Having direct access to the slider information would allow me to make my flows more complex without worrying about them falsely triggering. Tasker is able to read that file, so I am wondering what the difference in implementations is. My current workaround is to use a root command to read the file when the flows are triggered by an interruptions mode change, but it's hacky at best.
Edit: It's actually /sys/class/switch/tri-state-key/state
-
Desmanto
- Posts: 2709
- Joined: 21 Jul 2017 17:50
Post
by Desmanto » 11 Jan 2018 14:10
After I watch the video, I finally realize the alert slider is hardware.

Sorry, I never use OnePlus phone before, never knew there is this dedicated slider.
Strange thing is I try File Observer with /sys/class/power_supply/battery/capacity (literally the battery percentage), it works! It is because this file has pemission rw-r--r-- (644). File accessed, file opened and maybe others event also works. Sometimes It gives two event consecutively, so have to protect it with AEP - Skip. But for /data partition, it won't, it can't event list the file. However if you give automagic the permission group to access the folder, it may work.
So probably you should try File Observer to see if it can detect the changes.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
srichter
- Posts: 3
- Joined: 09 Jan 2018 16:32
Post
by srichter » 12 Jan 2018 23:05
Desmanto wrote:After I watch the video, I finally realize the alert slider is hardware.

Sorry, I never use OnePlus phone before, never knew there is this dedicated slider.
Strange thing is I try File Observer with /sys/class/power_supply/battery/capacity (literally the battery percentage), it works! It is because this file has pemission rw-r--r-- (644). File accessed, file opened and maybe others event also works. Sometimes It gives two event consecutively, so have to protect it with AEP - Skip. But for /data partition, it won't, it can't event list the file. However if you give automagic the permission group to access the folder, it may work.
So probably you should try File Observer to see if it can detect the changes.
Weird, I can't get events to fire for the capacity file, and I cannot access it with Init Variable Text File either. The permissions are the same. The ones for state are r-r-r so it should be able to access that one as well. What version of Android are you on? I'm using 7.1.2
-
Desmanto
- Posts: 2709
- Joined: 21 Jul 2017 17:50
Post
by Desmanto » 13 Jan 2018 05:30
Capacity is the percentage, it only change when the battery percentage change. I test it when leaving it on and put a debug dialog to inform me as soon as it triggered. Or you can just charge the phone, so it rise.
I can use Init text to show the battery percentage. I select the file using automagic default file selector (press the ellipsis). I am still using LP 5.1
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.