Screenshot interface is way better
This commit is contained in:
parent
d14b748536
commit
75b2b6e0b2
@ -1,35 +1,58 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if ! type scrot > /dev/null; then
|
name=`basename "$0"`
|
||||||
>&2 echo "!!! scrot is not installed"
|
|
||||||
exit 1
|
isInstalled() {
|
||||||
fi
|
type "$1" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
mustHaveInstalled() {
|
||||||
|
if ! isInstalled "$1"; then
|
||||||
|
echo "$name: $1 is not installed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $name [selection | window | screen] [clipboard]" >&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
picturesDir=`xdg-user-dir PICTURES`
|
picturesDir=`xdg-user-dir PICTURES`
|
||||||
test -z "$picturesDir" && picturesDir="$HOME/Pictures"
|
test -z "$picturesDir" && picturesDir="$HOME/Pictures"
|
||||||
picturesDir="$picturesDir/Screen Shots"
|
picturesDir="$picturesDir/Screen Shots"
|
||||||
|
|
||||||
if ! mkdir -p "$picturesDir"; then
|
if ! mkdir -p "$picturesDir"; then
|
||||||
>&2 echo "!!! can't create $picturesDir"
|
echo "$name: can't create $picturesDir" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
output="$picturesDir/`date -Iseconds`.png"
|
outputFilePath="$picturesDir/`date -Iseconds`.png"
|
||||||
|
|
||||||
|
mustHaveInstalled scrot
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"selection")
|
"selection" | "window" | "screen")
|
||||||
scrot --select --line style=dash --freeze --file "$output"
|
mode="$1"
|
||||||
clipArg="$2"
|
shift 1
|
||||||
;;
|
|
||||||
"window")
|
|
||||||
scrot --focused --border --file "$output"
|
|
||||||
clipArg="$2"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
scrot --file "$output"
|
mode="screen"
|
||||||
clipArg="$1"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if test "$clipArg" = "clipboard"; then
|
if [ "$1" = "clipboard" ]; then
|
||||||
xclip -selection clipboard -target image/png -i "$output"
|
clipboard=true
|
||||||
|
shift 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$#" -gt 0 ] && usage
|
||||||
|
|
||||||
|
case "$mode" in
|
||||||
|
"selection") scrot --select --line style=dash --freeze --file "$output";;
|
||||||
|
"window" ) scrot --focused --border --file "$output";;
|
||||||
|
"screen" ) scrot --file "$output";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -n "$copyToClipboard" ]; then
|
||||||
|
mustHaveInstalled xclip
|
||||||
|
xclip -selection clipboard -target image/png -i "$outputFilePath"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user