This smart NavBar action uses an app as the context and casts the relevant information to an active PC. It’s most useful if you want to continue media consumption on the PC of your choice. This could range from opening web interfaces of the apps (Facebook, Messenger, WhatsApp, Chrome) to sending device-specific commands.
What do I mean by “active PC”? This is the computer that has been used recently. I will base my tutorial on ActivePC write-up, so read that up for more details. I will use two ways of detecting the target machine to support more options. In the nutshell, you can cast to the target PC based on:
- location context (WIFI connected, when EventGhost can’t be used)
- system.unidle (EventGhost enabled PC)
In this example, I will use the Facebook app as the context and www.facebook.com page to be opened on the target machine. An icon representing my laptop, desktop, and a work computer will display dynamically in the smarter NavBar. These will update based on the location and the last computer used.
Smart NavBar: Cast to active PC
system.unidle events. These are created automatically when the computer is not used for 1 min or it’s woken up by an input device, respectively. The information which device is active is sent via AutoRemote to back to your phone. At any given time, Tasker knows which was the last used machine.
There is a minute cooldown associated with the idle messages being issued on the machines, so if you change your computer and return to the same machine, the status won’t be posted. You could fix that with some EventGhost magic from this write-up and your creativity.
Cast Facebook to active PC
The Tasker profile is simple, use Application context to show a new NavBar when Facebook is open. The NavBar contains the following configuration:
- task(name of the task followed by active device variable)[1.0]
The Smart NavBar will contain the icon of the active PC and will run the task responsible for sending the information to the PC.
I have created an Entry task which sets the variable %NBactiveApp to Facebook (needed if you going to have multiple apps) and assigns a correct NavBar. The exit task simply resets the NavBar to the default (back, centre, none) settings.
Device Location Profile
Because I promised the contextual control over PC’s that cannot run EventGhost, I can use also WiFi to override this profile. I will create another profile that sets the location to: home, work, or elsewhere. Once again, I will set the %DEVICELOCATION variable as this info can be used in different projects.
The location logic will be as follows:
- work (target my work PC)
- elsewhere (target my laptop)
- home (target the active PC)
If the phone is no longer connected the %DEVICELOCATION defaults to “elsewhere“.
Now that I have the location framework, I can use this to control the active PC profile.
Set Active PC Profile
I’d suggest sticking both profiles (Set Active PC & Device Location) into the “main” folder, as these can be referenced by other projects too! Especially, if you are interested in automating WhatsApp (coming soon).
Note that I have enclosed the Smart NavBar actions in IF statement, these actions are specific to Facebook action. I added the %DEVICELOCATION variable, as my dynamic options will only apply when I’m home. This way I can retain the information about the active PC without actually drawing a NavBar each time.
The active PC is stored in the variable %ACTIVEPC (if you want to know why in CAPS, read this article). Each time I change the computer, Tasker receives an AutoRemote message and updates the variable. To make my life less complicated, each computer name is taken from the Join App. I can use the verbatim spelling of the %ACTIVEPC variable to send messages to Join devices.
NB Facebook Laptop/Desktop/WiFi
The easiest way to update the icon in the NavBar was to create a duplicated task with the same action but different name and the icon.
The location based task is slightly different and uses %DEVICELOCATION to set the correct Join push action:
In this case, the devices are hardcoded! Join Push messages are send based only on the %DEVICELOCATION taken from the Locale profile.
Smart NavBar integration
This is a stand-alone version of the Smart NavBar actions. Once I created the standalone versions for each NavBar Task I will show you how to integrate it together. You can read the tutorial about this now!
Android NavBar is underutilised in my opinion, so it’s cool to add extra functionality without adding any additional menus. The contextual character of the NavBar means, that the action is there when you need it most. Next up, I will add extra smart NavBar actions to WhatsApp. If you have any comments or ideas, leave it in this Reddit thread.