Last active
December 21, 2015 17:38
-
-
Save Matt1360/6341566 to your computer and use it in GitHub Desktop.
Screenshot script I use for things like screenshots, and screenshot accessories that can be used with multiple X screens.For good things(tm), I recommend binding keyboard shortcuts to the script.I should also note, you want public keys set up to upload it. Yarr.
This file contains 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
#!/bin/bash | |
# Ensure some arg | |
if [ -z "$1" ] | |
then | |
echo "No arguments!" | |
exit -1 | |
fi | |
# Full screenshot - both X screens | |
if [ $1 = "full" ] | |
then | |
# Basically, for each display, take a screenshot, throw 'er in /tmp | |
import -window root -display :1.0 -screen /tmp/ss-0.png; | |
import -window root -display :1.1 -screen /tmp/ss-1.png; | |
# Now stitch 'em together | |
convert +append /tmp/ss-0.png /tmp/ss-1.png /tmp/screenshot.png; | |
# Clean 'em up | |
rm /tmp/ss-{0,1}.png; | |
# Single window | |
# Disclaimer: I've only tested this on my desktop and laptop | |
# Guarenteed happiness for all is not so guarenteed. | |
elif [ $1 = "win" ] | |
then | |
# Get some data from X | |
activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"); | |
activeWinId=${activeWinLine:40}; | |
# Take the screenshot | |
import -window "$activeWinId" /tmp/screenshot.png; | |
# Click and drag (pretty sweet, yeah) | |
elif [ $1 = "scroll" ] | |
then | |
# This is neat, it handles crap for me | |
import +repage /tmp/screenshot.png; | |
# Grab current X screen | |
elif [ $1 = "single" ] | |
then | |
# Simple, just take the root window of the current X screen | |
import -window root -screen /tmp/screenshot.png; | |
fi | |
# Get the timestamp | |
TIMESTAMP=`date +%s` | |
# Filepath | |
FILEPATH="/var/www/site.com/htdocs/screenshots/" | |
scp /tmp/screenshot.png site.com:$FILEPATH$TIMESTAMP.png | |
# Put it into our clipboard (middle click) | |
echo https://site.com/screenshots/$TIMESTAMP.png | xclip -selection clipboard | |
# Use lib-notify to tell us when it's ready, which is neat | |
notify-send 'Screenshot!' "Timestamp: ${TIMESTAMP}" | |
# EXIT ZEROS | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment