42 lines
794 B
Bash
Executable File
42 lines
794 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
stamp() {
|
|
date '+%s'
|
|
}
|
|
|
|
usage="Usage: $(basename $0) [options]
|
|
-F capture fullscreen
|
|
-q quiet
|
|
-h show this text"
|
|
|
|
while getopts 'Fqh' arg; do
|
|
case "$arg" in
|
|
F)
|
|
fullscreen=true;;
|
|
q)
|
|
quiet=true;;
|
|
h)
|
|
echo "$usage"
|
|
exit 0;;
|
|
*)
|
|
echo "$usage" >&2
|
|
exit 1;;
|
|
esac
|
|
done
|
|
shift $((OPTIND-1))
|
|
|
|
tmp_file="$(mktemp tmp.XXXXXXXXXX.png)"
|
|
file="$HOME/pics/screenshot_$(stamp).png"
|
|
if [ -n "$fullscreen" ]; then
|
|
DISPLAY=:0 import -window root "$file"
|
|
else
|
|
DISPLAY=:0 import "$tmp_file"
|
|
convert "$tmp_file" -shave 1x1 "$file"
|
|
rm "$tmp_file"
|
|
fi
|
|
|
|
xclip -selection clipboard -t image/png -i "$file"
|
|
|
|
[ -z "$quiet" ] && notify-send -i "$file" 'Screenshot taken'
|
|
[ -z "$quiet" ] && echo "$file"
|