Skip to content

Instantly share code, notes, and snippets.

@Aramgutang
Created April 22, 2013 00:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Aramgutang/5431798 to your computer and use it in GitHub Desktop.
Save Aramgutang/5431798 to your computer and use it in GitHub Desktop.
A Bash script to take regular screenshots of the Ingress Intel map for creating timelapses of operations.
#!/usr/bin/env bash
while [ 1 ]; do
# The --password-store=basic is there to avoid the KDE Wallet access
# request dialog on start-up.
google-chrome --password-store=basic --app=http://www.ingress.com/intel?ll=-33.781201,150.619812\&z=10 &
# Get the process ID, so we can kill it later
chrome_pid=$!
sleep 3
# Get the X window ID of the process we just started so we can resize it.
# Assumes you're not running any other apps with "chrome" in their name.
chrome_wid=`wmctrl -lpx | grep chrome | cut -c 1-10`
# Make sure the window isn't maximised, so resizing is allowed.
wmctrl -i -r $chrome_wid -b remove,maximized_vert,maximized_horz
# Make the window "always in top".
wmctrl -i -r $chrome_wid -b add,above
# Resize the window, making it large enough to crop out the comms at the
# bottom.
wmctrl -i -r $chrome_wid -e 1,0,0,2400,2100
# Wait for the intel map to load.
sleep 40
# Take a screenshot of the entire desktop, use ImageMagick to convert to
# PNG, and save in a "zoomed-in" subdirectory, using the current datetime
# as the filename.
xwd -root | convert - zoomed-in/$(date +%Y-%m-%d-%H.%M.%S).png
# Shut down Chrome.
kill "$chrome_pid"
sleep 2
# Do it all again at a different zoom level.
google-chrome --password-store=basic --app=http://www.ingress.com/intel?ll=-33.446109,149.898834\&z=8 &
chrome_pid=$!
sleep 3
chrome_wid=`wmctrl -lpx | grep chrome | cut -c 1-10`
wmctrl -i -r $chrome_wid -b remove,maximized_vert,maximized_horz
wmctrl -i -r $chrome_wid -b add,above
wmctrl -i -r $chrome_wid -e 1,0,0,2400,2100
sleep 40
xwd -root | convert - zoomed-out/$(date +%Y-%m-%d-%H.%M.%S).png
kill "$chrome_pid"
sleep 2
google-chrome --password-store=basic --app=http://www.ingress.com/intel?ll=-29.326874,134.250183\&z=6 &
chrome_pid=$!
sleep 3
chrome_wid=`wmctrl -lpx | grep chrome | cut -c 1-10`
wmctrl -i -r $chrome_wid -b remove,maximized_vert,maximized_horz
wmctrl -i -r $chrome_wid -b add,above
wmctrl -i -r $chrome_wid -e 1,0,0,2400,2100
sleep 40
xwd -root | convert - zoomed-far-out/$(date +%Y-%m-%d-%H.%M.%S).png
kill "$chrome_pid"
sleep 2
done
@Aramgutang
Copy link
Author

This was very last-minute, so the emphasis was on getting it done as quickly as possible, rather than figuring out the best way to do things.

Some notes:

  • This was run on a Linux machine with KDE as the window manager, but should work on Gnome or Xfce as well. The only requirements are Google Chrome, ImageMagick, and wmctrl.
  • My set-up is two monitors rotated into portrait orientation, so my desktop resolution is 2400x1920. The Chrome window gets resized to 2400x2100, putting the bottom part of the window with the comms outside of the desktop as a rudimentary way of cropping. A much better way to approach it is by using the -crop argument for the convert command.
  • I found that 40 seconds wasn't quite enough to have the intel map fully loaded each time at this resolution. I had to go through the images afterwards and manually delete some that still had "Loading data..." in the middle, or weren't showing some of the portals. About 1-2% of the images were culled in this process. Also, every once in a while (0.25% of the time), the map centring would be drastically off.
  • Instead of using xwd -root | convert to take the screenshot, it should also be possible to use import -window root, but due to an ImageMagick bug, the latter resulted in a black square over the Chrome window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment