Last active
January 15, 2017 11:04
-
-
Save Defman21/a0dcd8ad164928b4b7509f48ef5ee087 to your computer and use it in GitHub Desktop.
Elementary Screenshot script
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 | |
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