Skip to content

Instantly share code, notes, and snippets.

@flexiondotorg
Created January 16, 2020 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flexiondotorg/c1c517ec7e78dd6bc3b2308048dc0ba6 to your computer and use it in GitHub Desktop.
Save flexiondotorg/c1c517ec7e78dd6bc3b2308048dc0ba6 to your computer and use it in GitHub Desktop.
Take screenshots suitably scaled for use in Ubuntu Ubiquity slideshows.
#!/usr/bin/env bash
# Grab a screen shot of a window correct scaled for use in the
# Ubuntu Ubiquity slide shows.
RES_X=896
RES_Y=702
# Get the window we want to resize
TMP_XWININFO=$(mktemp -u)
echo -e "Please select the window you\nwould like to screenshot by clicking the\nmouse in that window."
xwininfo | tee ${TMP_XWININFO} > /dev/null
WINDOW_ID=$(grep "Window id:" ${TMP_XWININFO} | head -n1 | cut -d':' -f3 | cut -d' ' -f2)
rm -f ${TMP_XWININFO}
echo "Resizing: ${WINDOW_ID} to ${RES_X}x${RES_Y}"
# Set the resolution
wmctrl -i -r ${WINDOW_ID} -e 0,0,0,${RES_X},${RES_Y}
# Raise the window
wmctrl -i -R ${WINDOW_ID}
if [ -e $(which gnome-screenshot) ]; then
gnome-screenshot --window --delay=1 -f ${HOME}/slide-shot.png
if [ -e $(which convert) ]; then
convert -resize 50% ${HOME}/slide-shot.png ${HOME}/slide-shot-small.png
fi
else
echo "WARNING! No supported screenshot tool found."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment