Add support for grim
for screenshots
This commit is contained in:
parent
806e4373a7
commit
a8ea8e24e5
|
@ -16,8 +16,9 @@ Install the script and any dependencies and run it.
|
||||||
- If X11 is used
|
- If X11 is used
|
||||||
- maim
|
- maim
|
||||||
- If X11 is used
|
- If X11 is used
|
||||||
- wayshot
|
- grim OR wayshot
|
||||||
- If Wayland is used
|
- If Wayland is used
|
||||||
|
- grim tends to work a bit better from my experience, but both are supported.
|
||||||
- wl-clipboard
|
- wl-clipboard
|
||||||
- If Wayland is used
|
- If Wayland is used
|
||||||
- slurp
|
- slurp
|
||||||
|
|
|
@ -15,36 +15,32 @@
|
||||||
[ -z "$PREFIX" ] && PREFIX="screenshot-"
|
[ -z "$PREFIX" ] && PREFIX="screenshot-"
|
||||||
[ -z "$SEND_NOTIF" ] && SEND_NOTIF="true"
|
[ -z "$SEND_NOTIF" ] && SEND_NOTIF="true"
|
||||||
|
|
||||||
wait_scr() {
|
take_scr() {
|
||||||
[ -z "$2" ] && printf "You must specify a number\n" && exit 1
|
|
||||||
sleep "$2"
|
sleep "$2"
|
||||||
|
|
||||||
if [ "$x11" = "true" ]; then
|
if [ "$x11" = "true" ] && [ -x "$(command -v maim)" ]; then
|
||||||
maim -s"${ARG2}"B > "$1" || exit 1
|
maim -s"${ARG2}"B > "$1" || exit 1
|
||||||
else
|
elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v grim)" ]; then
|
||||||
|
grim -g "$(slurp)" - > "$1" || exit 1
|
||||||
|
elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v wayshot)" ]; then
|
||||||
wayshot --stdout -s "$(slurp)" > "$1" || exit 1
|
wayshot --stdout -s "$(slurp)" > "$1" || exit 1
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_full() {
|
|
||||||
[ -z "$3" ] && printf "You must specify a number.\n" && exit 1
|
|
||||||
sleep "$3"
|
|
||||||
|
|
||||||
if [ "$x11" = "true" ]; then
|
|
||||||
maim -"${ARG2}"B > "$1" || exit 1
|
|
||||||
else
|
else
|
||||||
wayshot --stdout > "$1" || exit 1
|
printf "Failed to take screenshot: Appropriate screenshot tools not found.\n" > /dev/stderr
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
full_scr() {
|
take_full() {
|
||||||
[ ! -e "$1" ] && [ "$x11" = "true" ] && maim -"${ARG2}"B > "$1" && return
|
sleep "$2"
|
||||||
[ ! -e "$1" ] && wayshot --stdout > "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
sel_scr() {
|
if [ "$x11" = "true" ] && [ -x "$(command -v maim)" ]; then
|
||||||
[ ! -e "$1" ] && [ "$x11" = "true" ] && maim -sB > "$1" && return
|
maim "${ARG2}"B > "$1" || exit 1
|
||||||
[ ! -e "$1" ] && wayshot --stdout -s "$(slurp)" > "$1"
|
elif [ -x "$(command -v grim)" ]; then
|
||||||
|
grim - > "$1" || exit 1
|
||||||
|
elif [ -x "$(command -v wayshot)" ]; then
|
||||||
|
wayshot --stdout > "$1" || exit 1
|
||||||
|
else
|
||||||
|
printf "Failed to take screenshot: Appropriate screenshot tools not found.\n" > /dev/stderr
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
send_notif() {
|
send_notif() {
|
||||||
|
@ -104,13 +100,8 @@ rm -f /tmp/screenshot*
|
||||||
# check arguments
|
# check arguments
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"") print_help; exit 0 ;;
|
"") print_help; exit 0 ;;
|
||||||
"-t")
|
"-f") take_full "/tmp/screenshot-$DATE" "0" ;;
|
||||||
[ "$2" = "-f" ] && wait_full "$@"
|
"-s") take_scr "/tmp/screenshot-$DATE" "0" ;;
|
||||||
|
|
||||||
wait_scr "/tmp/screenshot-$DATE" "$2"
|
|
||||||
;;
|
|
||||||
"-f") full_scr "/tmp/screenshot-$DATE" ;;
|
|
||||||
"-s") sel_scr "/tmp/screenshot-$DATE" ;;
|
|
||||||
*) print_help; exit 0 ;;
|
*) print_help; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -121,7 +112,7 @@ esac
|
||||||
[ ! -s "/tmp/screenshot-$DATE" ] && exit 0
|
[ ! -s "/tmp/screenshot-$DATE" ] && exit 0
|
||||||
[ -e "/tmp/screenshot-$DATE" ] && u_i="$(printf "${IMGPREFIX}${IMG}\tPNG\n${IMGPREFIX}${IMG}\tURL\n${IMGPREFIX}${IMG}\tSave\n" | $RUNLAUNCHER -l 3 -g 1 $IMGARG -p "Copy to clipboard as:")"
|
[ -e "/tmp/screenshot-$DATE" ] && u_i="$(printf "${IMGPREFIX}${IMG}\tPNG\n${IMGPREFIX}${IMG}\tURL\n${IMGPREFIX}${IMG}\tSave\n" | $RUNLAUNCHER -l 3 -g 1 $IMGARG -p "Copy to clipboard as:")"
|
||||||
|
|
||||||
if [ "$x11" = "true" ]; then
|
if [ "$x11" = "true" ] && [ -x "$(command -v maim)" ]; then
|
||||||
img_clipboard_cmd="xclip -selection clipboard -t image/png"
|
img_clipboard_cmd="xclip -selection clipboard -t image/png"
|
||||||
clipboard_cmd="xclip -selection clipboard"
|
clipboard_cmd="xclip -selection clipboard"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue