Created
April 22, 2013 00:58
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
-crop
argument for theconvert
command.xwd -root | convert
to take the screenshot, it should also be possible to useimport -window root
, but due to an ImageMagick bug, the latter resulted in a black square over the Chrome window.