Tasker detecting itself

262 views
Skip to first unread message

Jeremy Harris

unread,
Jan 14, 2015, 11:35:53 AM1/14/15
to tas...@googlegroups.com
I have read the FAQ and fully understand the risks of using Tasker in an app context, and why Pent has removed the temptation.

I have 2 profiles (one Proximity context, the other is a Shake context) which are very useful in that they trigger a task which kills the app in foreground. The profiles are toggled on/off by which 'mode' I'm in (home/car/work/etc). If I'm in Tasker while one of these profiles is on, I occasionally trigger the context accidentally and kill Tasker unexpectedly, losing work.

I've worked around this by creating a shortcut to a task that toggles the profiles Off, then launches Tasker. Now I need to return those profiles to the state they were in previously, upon exiting Tasker.

My idea is to trigger on a File Modified context on the newly created userbackup.xml the /AutoBackups/ directory but the file is stored in a folder named by time (to the second), and is difficult to identify dynamically.

Is there a different approach to detect if Tasker has closed?

I've thought about monitoring the pid/oom of Tasker when I open it, then triggering when the value indicates that it is in the background...I could probably make that work, but certainly there's a better way?

Jeremy Harris

unread,
Jan 14, 2015, 11:55:39 AM1/14/15
to tas...@googlegroups.com

To clarify:

My idea is to trigger on a File Modified context

...or on any other File event type.

I've thought about monitoring the pid/oom of Tasker when I open it, then triggering when the value indicates that it is in the background...

The reason this is not my first choice is to avoid my runlogs getting cluttered by a looping task that will always run when Tasker is open... making debugging a nightmare.

Rich D

unread,
Jan 14, 2015, 12:58:42 PM1/14/15
to Tasker Google Groups Post


> I've worked around this by creating a shortcut to a task that toggles the profiles Off, then launches Tasker.

That means you will always launch tasker from your home screen, correct?  And that is where you will end up when exiting tasker.

So I think you could turn on a profile that monitors %WIN when you. Start tasker and when it matches your home screen turn on the other 2 profiles and turn off the %WIN profile.  Even if you you end up starting another app from the notify bar I am sure you will hit your home screen fairly soon after.. 

Just one thought..


Jeremy Harris

unread,
Jan 14, 2015, 1:30:11 PM1/14/15
to tas...@googlegroups.com

Well, that is an approach I had not considered. It won't be that easy, but i might be able to work with that concept to fit.

That means you will always launch tasker from your home screen, correct?

Sometimes, but not usually.  I do have the shortcut on my homescreen, but i mostly launch tasker (from that shortcut) via my 'Pie' which overlays Nova launcher and any foreground app. So I don't always return to homescreen.

I'll see if I can run with %WIN though, to make it work. :)

Screenshot_2015-01-14-13-20-55.png

Jeremy Harris

unread,
Jan 14, 2015, 2:38:39 PM1/14/15
to tas...@googlegroups.com
I was thinking of doing:

Var Set [%ClosedTasker to:1] If [%WIN !~ *Tasker*]

...or something like that...but it appears that the window name for tasker does not appear in %WIN. I get 'home' as if I'm still on the homescreen. Accessibility is on, and %WIN sends to load accurately when other apps are launched.

Rich D

unread,
Jan 14, 2015, 3:16:16 PM1/14/15
to Tasker Google Groups Post


> ...or something like that...but it appears that the window name for tasker does not appear in %WIN.

Perhaps others  could post there findings but this is where it gets strange on my device.  If I have tasker enabled in accessibility settings then I do not get a window value for tasker.

However if I "Do Not" have tasker enabled but have another app enabled in the accessibility settings   then I do get a window value for tasker using %WIN with tasker.   You might need to read that again but I assure you it is correct.. 

In other words as long as any app is enabled in the accessibility settings then tasker does not have to be enabled. For %WIN to work "And" I get a window value for tasker.

@jeremy,  you might try making a app factory app to monitor %WIN for 'Tasker'.   I know your device has some issues with tasker apps and accessibility but it might be worth a shot.. 

Jeremy Harris

unread,
Jan 15, 2015, 5:04:46 PM1/15/15
to tas...@googlegroups.com

but this is where it gets strange on my device.

Well, I can confirm that %WIN does not load if Accessibility is enabled for Tasker, and that when I disable accessibility for Tasker and leave it enabled for another app, I can confirm that %WIN does contain a value....but does yours say "Stop Tasker?"

Weird. See screenie.

Screenshot_2015-01-15-16-59-22.png

Jeremy Harris

unread,
Jan 15, 2015, 5:10:13 PM1/15/15
to tas...@googlegroups.com

@jeremy,  you might try making a app factory app to monitor %WIN for 'Tasker'.   I know your device has some issues with tasker apps and accessibility but it might be worth a shot.. 

That's a good idea to make an external app. I think I'll end up monitoring the oom value with a kid app that prints a line to a file when Tasker closes. Then a File Modified context to trigger a task that toggles the profile status.

That should be fairly accurate/responsive and will keep the runlog from all that clutter.

Rich D

unread,
Jan 15, 2015, 5:23:30 PM1/15/15
to Tasker Google Groups Post

> Well, I can confirm that %WIN does not load if Accessibility is enabled for Tasker, and that when I disable accessibility for Tasker and leave it enabled for another app, I can confirm that %WIN does contain a value....but does yours say "Stop Tasker?"

No, mine just says 'Tasker'.  Do you get the 'Stop Tasker' when you first open tasker?

Perhaps it is the version, I am on Version: 4.6u3m

>
> Weird. See screenie.

Jeremy Harris

unread,
Jan 15, 2015, 5:30:50 PM1/15/15
to tas...@googlegroups.com

Yeah, i just updated to u3 and I still get 'Stop Tasker?' and it is the same, even after closing and relaunching tasker.

Jeremy Harris

unread,
Jan 15, 2015, 9:02:31 PM1/15/15
to tas...@googlegroups.com

From the FAQ:

Why isn't Tasker shown in the Application Context list ?

Because it's easy to get into trouble firing tasks in Tasker. For example, if a profile is setup with a Tasker Application Context and a task with Load App Calculator, it will not be possible to enter Tasker anymore.

http://tasker.dinglisch.net/userguide/en/faqs/faq-why.html

With that said... This task works perfectly, exported as an app and in conjunction with a File Modified context.  Response from tasker closing, to kid app detecting and writing file, to profile activated is about one second.  :)

Detect Tasker (355)
Run Both Together
A1: Variable Set [ Name:%newline To:
Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%space To:  Do Maths:Off Append:Off ]
A3: Run Shell [ Command:ps Timeout (Seconds):0 Use Root:Off Store Output In:%apps Store Errors In: Store Result In: ]
A4: Write File [ File:appz Text:%apps Append:Off Add Newline:On ]
A5: [X] Stop [ With Error:Off Task: ]
A6: Variable Split [ Name:%apps Splitter:net.dinglisch.android.taskerm Delete Base:Off ]
A7: Variable Split [ Name:%apps1 Splitter:%newline Delete Base:Off ]
A8: Variable Set [ Name:%last To:%apps1(#) Do Maths:Off Append:Off ]
A9: Variable Set [ Name:%taskerpidline To:%apps1(%last) Do Maths:Off Append:Off ]
A10: Variable Split [ Name:%taskerpidline Splitter:%space Delete Base:Off ]
A11: Variable Set [ Name:%taskerpid To:%taskerpidline4 Do Maths:Off Append:Off ]
A12: Run Shell [ Command:cat /proc/%taskerpid/oom_adj Timeout (Seconds):0 Use Root:Off Store Output In:%oom Store Errors In: Store Result In:%Aresult ]
A13: [X] Flash [ Text:%oom Long:Off ]
A14: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]
A15: Goto [ Type:Action Number Number:1 Label: ] If [ %oom < 2 ]
A16: Write File [ File:DetectTasker/shutdownlog.txt Text:%DATE  %TIME Append:On Add Newline:On ]

Jeremy Harris

unread,
Jan 15, 2015, 10:09:49 PM1/15/15
to tas...@googlegroups.com

...and that weird value contained in %win? It's coming from the title of a popup alert that I get when I toggle the accessibility service off for tasker, in android settings.

Screenshot_2015-01-15-21-21-40.png
Reply all
Reply to author
Forward
0 new messages