Tasker timers – Close incognito chrome & WI-FI when no longer in use

In a recent email, I have been asked to create a profile which would close the incognito chrome tabs if left unattended for some time. I think this is a great introduction to the correct way to create a Tasker timers. You have probably seen actions ‘Wait‘ and ‘Wait until‘. Not as CPU heavy as they used to be, however still little cumbersome in handling. I will show you how to create a timer, that can be easily changed, updated or canceled.

Tasker timers – how to

The theory behind this is simple. Instead of creating a countdown, and employ the CPU to do the counting, you can create a timestamp, that you wish to act upon. Doing it this way, allows you to avoid collision handling, and it is the most battery friendly solution. I will guide you through two profiles that are using timers to work. I hope this will illustrate the benefits of handing the timers this way. And also prevent the strangers from looking up your incognito tabs.

Follow the video or read on for all the instructions. Links to the project files can be found in the video description.

The project is very simple. Contains only 2 profiles, which handle setting the time stamp, and closing chrome window. To close the chrome incognito tabs we will use a run shell action. Root will be required, however, it is possible to do this with AutoInput plugin, by pressing on the incognito chrome notification in the status bar. In time context, instead of setting a numeric value, choose the variable icon. Populate both From and To fields as this way context will act like an event. We are going to change the value of the variable to drive the entire profile. Link this profile to a new task – run shell, and execute:

am force-close com.android.chrome

(make sure use Root is selected)

Then use Variable Clear to clear the time context variable.

The second profile will set the timer for us. We want this to happen when a display is off, and when chrome incognito tabs are present. When the incognito tab is opened a notification is created, and it stays there as long as tabs are open. I will use to contexts: Display off and AutoNotification Intercept (fill from existing – to match the app, title, and text). This profile will have 2 tasks Entry task will set the timer – Variable set:

%TIMES+300
(Do Math)

The %TIMES variable is the current time in seconds, and to get the time stamp 5 min ahead of time, we will simply add 300sec to the value. This value will be used in the first profile. Our exit task will simply clear the variable. This way we can reset this task multiple times.

With this profile active, you should no longer get caught with your incognito tabs down.

Another Tasker timer is the WIFI auto off. Using the same principle, we will disconnect the wifi, if it’s no longer connected to any of the networks. It saves the battery and works whenever you leave a known area. In addition to the previous routine, notifications will be created to let us know about the pending job.

First profile will have the same construction. Use time context and set the time values From and To to the same variable, then create the task and use WIFI off action in the Tasker. Once this is done, we want to clear the variable and make sure that no notification is present. Autonotification Cancel and fill in ID 11.

The second profile will set the timer and create a notification. We will have two contexts to act upon. State: WIFI connected (inverse) and variable %WIFI – on as we want to use this only when WIFI is not connected, and it is enabled. Putting your phone in the airplane mode will result in WIFI not connected context being met. Entry task will consist of setting the time variable to %TIMES+300 as done previously. Because we want to create a notification that will contain the time of this event, another action will convert this value to a readable time. Use Variable Convert to change the value from seconds to Date Time, and store it in a local variable. If you use a local variable, there will be no need to clear it later. Lastly, create a notification, with a text of your choosing and information consisting that local variable of your choice. Set the notification ID to 11.

Our Exit task will make sure the time variable is cleared and notification is canceled (use ID 11 to do this).

Conclusion

This is the most flexible and efficient way to get your tasker timers done. It takes very little CPU, you can manage the timers at any point, and you won’t run into issues with collision handling. I hope these profiles will become a part of your set up. Tasker project file and additional information can be found on here.

Happy Tasking!

Share this:

About the Author

I am passionate about technology, cycling, and art. This would explain why my bike has more computing power than your average office. I own notenoughtech.com and I write for xda-developers.com and pocketables.com
Feel free to follow me!