Page 1 of 1
Optimal approach for App Start/End & setting state?
Posted: 19 Sep 2016 15:19
by GollyJer
Hi! Long time Tasker user who just switched over to Automagic. LOVE it! After a small learning curve I'm recreating many tasks as flows and they are MUCH easier to understand on one nice clean canvas.
Here's my question. I am hoping to get a best-practice approach.
1) When the camera starts, turn on auto-rotate.
2) When the camera ends, turn off auto-rotate unless it was on before the camera started.
I have an approach that uses multiple flows and a global variable to track the current auto-rotate state but it feels clunky. Is this possible to do in one clean flow?
Thanks!
Re: Optimal approach for App Start/End & setting state?
Posted: 19 Sep 2016 18:48
by MURTUMA
You can use multiple triggers in one flow and differentiate between them with condition Expression: "trigger == nameofthetrigger". In small flows this is handy, but large flows could be easier to maintain when each "path" has its own flow.
In your case, I'd do it by merging app started and ended flows and having separate flow for tracking the orientation setting state.
Performance vise merging flows usually forces to make a few more conditions but practically the impact is unnoticeable. Thus it is more your personal preference how you want to do things.
Re: Optimal approach for App Start/End & setting state?
Posted: 19 Sep 2016 19:50
by GollyJer
Thanks for the help Murtuma.
Follow up...
Is there a "one-block" way to store the current state of auto-rotate?
I realize I can use the condition "Auto-rotate Screen Enabled" and then follow the "True" line and create a script to set my global variable to true.
I was hoping to use one script block to say
Code: Select all
my_auto_rotate_state == 'Auto-rotate Screen Enabled'
Possible?
Thanks again!
Re: Optimal approach for App Start/End & setting state?
Posted: 20 Sep 2016 06:36
by MURTUMA
I'm not exactly sure what you are asking so I'll shoot answers blindly hoping one would hit.
How are you keeping track of the setting currently?
Trigger
System setting changed: category: system, name: accelometer_rotation stores the value in variable
setting by default. You can change it to
global_setting. Then you can check the value with condition
Expression in other flows. You won't need anything else but one trigger to keep track of the setting and conditions to check the value in relevant flows. No scripts are needed.
Or you can do that straight in the relevant flow with action
Init variable system setting: category: system, name: accelometer_rotation. The action stores the value in variable
setting which you can check with condition
Expression. That way you don't need another flow to keep track of it.
Re: Optimal approach for App Start/End & setting state?
Posted: 20 Sep 2016 16:59
by GollyJer
Haha! Yes! I was vague enough that you had to give me all the ways to do it.
Init variable system settings is
exactly what I was looking for but didn't know it.
I was using Execute Command with
settings get system accelerometer_rotation and setting the variable myself. The built in Init variable is much faster. Thanks!
One last question along the same lines, if you don't mind.
The rom/kernel I'm using allows for a
High Brightness Mode.
I can turn it off and on using Execute Root Command.
on echo 1 > /sys/devices/virtual/graphics/fb0/hbm
off echo 0 > /sys/devices/virtual/graphics/fb0/hbm
Is there some magical way to read the state of that path before turning it on/off?
Thanks again! I'm trying to learn quickly. Forum search works OK, but not great.