HomeTaskerGoogle Maps - commute traffic as your wallpaper/lock screen wallpaper

Google Maps – commute traffic as your wallpaper/lock screen wallpaper

How about live traffic updates as your lock screen wallpaper?

There is a tutorial made by Joao Dias showing you how to set NASA daily pictures as wallpaper. I thought, I would up the ante a little. When I started to work on this project, I thought it will be a quick one. Turned out, the solution was more difficult than initially anticipated. A 5 min tutorial turned into a several hours long mad googling session! I REALLY hope you will like the Google Maps traffic wallpaper.

Without further introductions, here is Google Maps traffic wallpaper. This wallpaper is set for a period of time before commute to and from work. Could you just ask Google for this information? Yes, you can do that, however, I find this to be less intrusive, you don’t have to think about it and the information is ready when you need it most. It’s a great addition to your Google Now updates.

Map – the issue

map

The information is best obtained by taking a screenshot. This is not that simple if your phone has a screen lock on it. I can force the Tasker to take the screenshot – whether with a Run Shell, AutoTools etc. But most of the time I would end up with a black screen, or lock screen picture.

I had to scrap this idea and come up with something else. While googling for solutions I came across screenshot services like screenshotmachine.com. The free account allows you for a 100 API calls per month. The API is pretty much self-explanatory. I got stuck for a long time with the fact that my link was able to pull a correct image via the web browser but not through the HTTP GET action. I managed to bypass the link issue by using the Google URL shortener. It worked.

Profile

screenshot_20161013-063042

The context is simple (feel free to change it). I’m using a time condition to change the current wallpaper for 30 min before my commute to work, and before my return home. Outside of these times, the wallpaper will revert to one of your choices. You can use the Tasker to set the wallpaper, and if you on Android 7 you can use AutoTools to set the screen lock wallpaper separately.

Task

Formatting the link

As per API guide, the link looks like this:

https://api.screenshotmachine.com/?key=YOUR_API_KEY&size=F&cacheLimit=0&format=PNG&url=URL_SHORTENED_BY_GOOGLE

Open up the google maps and get the directions for your commute (both ways) and cut the link short before the encoded part. (The link has been updated with the &cacheLimit=0 to prevent the request from getting the cached image – credit: Zach Paiz) Here is my example and here is where it ends (remove stuff associated with/data=!3m1…. these are the time of travel and we want to have this generated each time):

https://www.google.co.uk/maps/dir/Field+View+B+%26+B+Yarm,+Green+Lane,+Yarm+TS15+9EH,+United+Kingdom/Manchester+Piccadilly+Station,+Manchester+M60+7RA,+United+Kingdom /(dont need the rest)....../data=!3m1!4b1!4m13!4m12!1m5!1
TASKER Profile:Going Home
Profile: Coming Back Home 
	Time: From 18:30 Till 19:00
Enter: Get Map Return 
		Abort Existing Task
	A1: Variable Set [ Name:%UrlCommute To:SHORT_URL_HERE
            Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: HTTP Get [ Server:Port:https://api.screenshotmachine.com/
            ?key=YOUR_KEY_HERE&size=X&format=PNG&cacheLimit=0&url=%UrlCommute
            Path: Attributes: Cookies: User Agent: Timeout:15 
            Mime Type:image/png Output File:/sdcard/Tasker/new.png 
            Trust Any Certificate:On ] 
	A3: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ] 
	A4: Load Image [ Source:/sdcard/Tasker/new.png 
            Max Width Or Height:0 Respect EXIF Orientation:Off ] 
	A5: Crop Image [ From Left (%):45 From Right (%):0 
            From Top (%):0 From Bottom (%):0 ] 
	A6: Save Image [ File:/sdcard/Tasker/new1.png 
            Image Quality:85 Delete From Memory After:On ] 
	A7: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper: 
            /storage/emulated/0/Tasker/new1.png
            Timeout (Seconds):60 ] 

Exit: Reset 
	A1: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper: 
            /storage/emulated/0/Download/IMG_20160923_104847.jpg 
            Timeout (Seconds):60 ]
TASKER Profile:Going to Work
Profile: Going To Work 
	Time: From 06:45 Till 08:15
Enter: Get Map 
	Abort Existing Task
	A1: Variable Set [ Name:%UrlCommute To:SHORT_URL_HERE 
            Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: HTTP Get [ Server:Port:https://api.screenshotmachine.com/
            ?key=YOUR_KEY_HERE&size=X&format=PNG&cacheLimit=0&url=%UrlCommute 
            Path: Attributes: Cookies: User Agent: Timeout:15 
            Mime Type:image/png Output File:/sdcard/Tasker/new.png 
            Trust Any Certificate:On ] 
	A3: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ] 
	A4: Load Image [ Source:/sdcard/Tasker/new.png 
            Max Width Or Height:0 Respect EXIF Orientation:Off ] 
	A5: Crop Image [ From Left (%):45 From Right (%):0 
            From Top (%):0 From Bottom (%):0 ] 
	A6: Save Image [ File:/sdcard/Tasker/new1.png 
            Image Quality:85 Delete From Memory After:On ] 
	A7: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper: 
            /storage/emulated/0/Tasker/new1.png Timeout (Seconds):60 ] 

Exit: Reset 
	A1: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper:
            /storage/emulated/0/Download/IMG_20160923_104847.jpg
            Timeout (Seconds):60 ]
this-one

Use that google code with the URL shortener if it doesn’t work directly for you to compile the final screenshot API request. I’m going to use HTTP GET to receive the picture of the current traffic and route options. As both routes will use exactly the same routines but different links it makes sense to set the shortened links as variable %UrlCommute. In the action set the link + the variable in the Server:Port. Set the Mime Type to Image/png and select a file location. This is where the picture will be stored. Before the image can be used – we will need to crop it.

Cropping

If you selected the image to be full size (X) you will end up with a consistent image of 1024 x 768px. This is far from perfect and the crop is in place. You can use both information if you wish. The list view and the map view but I will show you the cropping to get the map. You will need 3 actions. Load, Crop and Save image. Crop from the left 45%.

Wallpaper

Using Muzei and AutoTools you can set the new wallpaper to both home screen and lock screen. If you are using Tasker actions only you will be limited to a home wallpaper only. Select the correct files and you are ready to rock.

Finishing the project Google Maps traffic wallpaper

After reading all this, I’d assume you will have no problem with setting up a profile for the reversed journey. You don’t even have to change the file names.  only reverse the link and set up a  new time.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?