Skip to content

Instantly share code, notes, and snippets.

@appastair
Forked from Aramgutang/timelapse.sh
Created November 3, 2017 04:12
Show Gist options
  • Save appastair/468a8dda0a3173d775a517cdb9253503 to your computer and use it in GitHub Desktop.
Save appastair/468a8dda0a3173d775a517cdb9253503 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment