PocketablesAndroidGood and EVOTaskerTutorials

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.

Close incognito tabs when left open for five minutes

 

Tasker timers

Profile: Set Chrome Timer
State: Display State [ Is:Off ] State: AutoNotification Intercept [ Configuration:Event Behaviour: false
Persistency Type: Persistent Only
Has Reply Action: false
Notification Title: Chrome
Notification Text: Close all incognito tabs
Get All Fields : false
Get Internal Actions: false
Get Internal Actions Big: false ] Enter: Set Chrome Timer
A1: Variable Set [ Name:%ChromeTimer To:%TIMES+300 Do Maths:On Append:Off ]

Exit: Cancel Termination
A1: Variable Clear [ Name:%ChromeTimer Pattern Matching:Off ]

Profile: Close Chrome
Time: From %ChromeTimer Till %ChromeTimer
Enter: Terminate Incognito
A1: Run Shell [ Command:am force-stop com.android.chrome Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ] A2: Variable Clear [ Name:%ChromeTimer Pattern Matching:Off ]

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.

Close WIFI if not connected for five minutes

Tasker timer WIFI

Profile: Turn Off wifi (40)
Time: From %WifiTimer Till %WifiTimer
Enter: Turn Off Wifi (41)
A1: WiFi [ Set:Off ] A2: Variable Clear [ Name:%WifiTimer Pattern Matching:Off ] A3: AutoNotification Cancel [ Configuration:Id: 11
Cancel All: false Timeout (Seconds):0 ]

Profile: Set The Timer (42)
State: Not Wifi Connected [ SSID:* MAC:* IP:* ] State: Variable Value [ %WIFI ~ on ] Enter: Not Connected To Wifi (43)
A1: Variable Set [ Name:%WifiTimer To:%TIMES+300 Do Maths:On Append:Off ] A2: Variable Convert [ Name:%WifiTimer Function:Seconds to Date Time Store Result In:%wifitermination ] A3: AutoNotification [ Configuration:Use HTML: false
Title: WIFI will turn off shortly
Text: I will turn off at %wifitermination
Icon: android.resource://net.dinglisch.android.taskerm/hl_device_access_network_wifi
Status Bar Icon: alerts_and_states_error
Status Bar Text Size: 16
Id: 11
Is Group Summary: false
Title Expanded: WIFI will turn off shortly
Skip Picture Cache: false
Text Expanded: I will turn off at%wifitermination
Update Notification: false
Only on Phone: false Timeout (Seconds):20 ]

Exit: Connected To Wifi (44)
A1: Variable Clear [ Name:%WifiTimer Pattern Matching:Off ] A2: AutoNotification Cancel [ Configuration:Id: 11
Cancel All: false Timeout (Seconds):0 ]

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!

Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!
Become a patron at Patreon!

Mat Zolnierczyk

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 NotEnoughTECH | Facebook | Twitter |YouTube |Instagram | Google+ |Donate |Patreon

Avatar of Mat Zolnierczyk