Skip to content

Instantly share code, notes, and snippets.

@Defman21
Last active January 15, 2017 11:04
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 Defman21/a0dcd8ad164928b4b7509f48ef5ee087 to your computer and use it in GitHub Desktop.
Save Defman21/a0dcd8ad164928b4b7509f48ef5ee087 to your computer and use it in GitHub Desktop.
Elementary Screenshot script
#!/bin/bash
FILE="$HOME/tmp.png"
PROGRAM="$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_CLASS | awk -F: 'BEGIN { FS="="; } {print $2}' | awk 'match($1,/[a-z-]+/) {print substr($1,RSTART,RLENGTH)}')"
GTKVERSION="$(ldd /usr/bin/$PROGRAM | grep libgtk | awk '{print $1;}' | tail -n1)"
SCRPROGRAM="gnome-screenshot $1 -e none -f $FILE"
REGEX="libgt(k|kd)-3*"
if [[ $GTKVERSION =~ $REGEX && $1 == "-w" ]]
then
SCRPROGRAM="screenshot-tool -w"
$SCRPROGRAM && cat "$FILE" | xclip -se c -t image/png && rm "$FILE"
else
SHADOWSIZE="55x14+0+19"
if [[ $1 == "-a" ]]; then
SHADOWSIZE="50x3+0+3"
fi
$SCRPROGRAM
convert "${FILE}" \( +clone -background black -shadow $SHADOWSIZE \) +swap -background transparent -layers merge +repage "$FILE"
cat "$FILE" | xclip -se c -t image/png && rm "$FILE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment