add wayland support to screenshotutil
im going to rewrite all scripts here though
This commit is contained in:
parent
50ecfe3bfc
commit
ac13d81aeb
|
@ -2,15 +2,41 @@
|
|||
# speedwm-screenshotutil
|
||||
# screenshot script
|
||||
#
|
||||
# dependencies: curl, maim and xclip.
|
||||
# x11 dependencies: curl, maim and xclip.
|
||||
# wayland dependencies: curl, wayshot, slurp, wl-clipboard
|
||||
#
|
||||
# curl snippet for imgbb by nezbednik, thank you!
|
||||
|
||||
# basic functions for taking the screenshots
|
||||
SLEEP() { sleep "$2" && maim -s"${ARG2}"B > "$1"; }
|
||||
SLEEP_AND_FULL() { sleep "$3" && maim -"${ARG2}"B > "$1" || exit 0; }
|
||||
FULL_SCR() { [ ! -e "$1" ] && maim -"${ARG2}"B > "$1" || return 0; }
|
||||
SEL_SCR() { [ ! -e "$1" ] && maim -s"${ARG2}"B > "$1" || return 0; }
|
||||
SLEEP() {
|
||||
sleep "$2"
|
||||
|
||||
if [ "$x11" = "true" ]; then
|
||||
maim -s"${ARG2}"B > "$1" || exit 1
|
||||
else
|
||||
wayshot --stdout -s "$(slurp)" > "$1" || exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
SLEEP_AND_FULL() {
|
||||
sleep "$3"
|
||||
|
||||
if [ "$x11" = "true" ]; then
|
||||
maim -"${ARG2}"B > "$1" || exit 1
|
||||
else
|
||||
wayshot --stdout > "$1" || exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
FULL_SCR() {
|
||||
[ ! -e "$1" ] && [ "$x11" = "true" ] && maim -"${ARG2}"B > "$1" && return
|
||||
[ ! -e "$1" ] && wayshot --stdout > "$1"
|
||||
}
|
||||
|
||||
SEL_SCR() {
|
||||
[ ! -e "$1" ] && [ "$x11" = "true" ] && maim -s"${ARG2}"B > "$1" && return
|
||||
[ ! -e "$1" ] && wayshot --stdout -s "$(slurp)" > "$1"
|
||||
}
|
||||
|
||||
# functions for sending notifications
|
||||
SENDNOTIF() { command -v notify-send > /dev/null && notify-send "$1"; }
|
||||
|
@ -48,6 +74,8 @@ IMAGE_SIZE="500"
|
|||
CACHE_IMAGE="false"
|
||||
CONFIG
|
||||
|
||||
pgrep -x X > /dev/null && x11=true
|
||||
|
||||
# showcursor
|
||||
[ "$SHOWCURSOR" = "true" ] && ARG2="" || ARG2=u
|
||||
|
||||
|
@ -89,10 +117,18 @@ esac
|
|||
[ ! -s "/tmp/screenshot-$DATE" ] && exit 0
|
||||
[ -e "/tmp/screenshot-$DATE" ] && U_INPUT="$(printf "${IMGPREFIX}${IMG}\tPNG\n${IMGPREFIX}${IMG}\tURL\n${IMGPREFIX}${IMG}\tSave\n" | $RUNLAUNCHER -l 3 $IMGARG -p "Copy to clipboard as:")"
|
||||
|
||||
if [ "$x11" = "true" ]; then
|
||||
img_clipboard_cmd="xclip -selection clipboard -t image/png"
|
||||
clipboard_cmd="xclip -selection clipboard"
|
||||
else
|
||||
img_clipboard_cmd="wl-copy"
|
||||
clipboard_cmd="wl-copy"
|
||||
fi
|
||||
|
||||
# perform actions based on user input
|
||||
case "$U_INPUT" in
|
||||
"PNG") cat "/tmp/screenshot-$DATE" | xclip -selection clipboard -t image/png && SENDNOTIF "Screenshot copied to clipboard." ;;
|
||||
"URL") printf "\n" | xclip -selection clipboard && UPLOAD_IMAGE "/tmp/screenshot-$DATE" | xclip -selection clipboard && SENDNOTIF "Screenshot copied to clipboard." ;;
|
||||
"PNG") cat "/tmp/screenshot-$DATE" | $img_clipboard_cmd && SENDNOTIF "Screenshot copied to clipboard." ;;
|
||||
"URL") printf "\n" | $clipboard_cmd && UPLOAD_IMAGE "/tmp/screenshot-$DATE" | $clipboard_cmd && SENDNOTIF "Screenshot copied to clipboard." ;;
|
||||
"Save") SAVEDIR=$(printf "%s/screenshot-%s.png" "$DEFAULT_SCREENSHOT_DIRECTORY" "$(date "$FORMAT" | sed "s|:|-|g" | sed "s|/||g")" | $RUNLAUNCHER -l 1 -g 1 -p "Where do you want to save it? (Including filename)" -im) && cat /tmp/screenshot-"$DATE" > "$SAVEDIR" && SENDNOTIF "Screenshot saved to $SAVEDIR" ;;
|
||||
"") rm -f "/tmp/screenshot*"; exit 0 ;;
|
||||
*) HELP "$@"; exit 0 ;;
|
||||
|
|
Loading…
Reference in a new issue