From c9ffb8ef476cb84ee4d5ddd48c072273ec771fc8 Mon Sep 17 00:00:00 2001 From: speedie Date: Tue, 12 Sep 2023 16:53:00 +0200 Subject: [PATCH] Fix some small issues with last commit --- screenshot-spmenu | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/screenshot-spmenu b/screenshot-spmenu index b223022..6a0af71 100755 --- a/screenshot-spmenu +++ b/screenshot-spmenu @@ -8,6 +8,7 @@ IMAGE_SIZE="${IMAGE_SIZE:-500}" CACHE_IMAGE="${CACHE_IMAGE:-false}" SCREENSHOT_CONFIG_DIR="${SCREENSHOT_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/screenshot-spmenu}" SHOW_CURSOR="${SHOW_CURSOR:-true}" +PREFER_WAYSHOT="${PREFER_WAYSHOT:-false}" DEFAULT_SCREENSHOT_DIRECTORY="${DEFAULT_SCREENSHOT_DIRECTORY:-$HOME/Screenshots}" FORMAT="${FORMAT:-+%T_%D}" PREFIX="${PREFIX:-screenshot-}" @@ -23,16 +24,22 @@ screenshot_take() { [ "$2" = "true" ] && [ "$x11" != "true" ] && POS="$(slurp)" if [ "$x11" = "true" ] && [ -x "$(command -v maim)" ]; then - [ "$2" = "true" ] && sel_arg="-s $POS" + [ "$2" = "true" ] && sel_arg="-s" [ "$3" = "true" ] && [ "$2" != "true" ] && cursor_arg=u - maim -s"${cursor_arg}"B > "$1" || exit 1 - elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v grim)" ]; then - [ "$2" = "true" ] && sel_arg="-g $POS" - grim "$sel_arg" - > "$1" || exit 1 + maim -"${sel_arg}""${cursor_arg}"B > "$1" || exit 1 + elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v grim)" ] && [ "$PREFER_WAYSHOT" != "true" ]; then + if [ "$2" = "true" ]; then + grim -g "$POS" - > "$1" || exit 1 + else + grim - > "$1" || exit 1 + fi elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v wayshot)" ]; then - [ "$2" = "true" ] && sel_arg="-s $POS" - wayshot --stdout "$sel_arg" > "$1" || exit 1 + if [ "$2" = "true" ]; then + wayshot --stdout -s "$POS" > "$1" || exit 1 + else + wayshot --stdout > "$1" || exit 1 + fi else printf "Failed to take screenshot: Appropriate screenshot tools not found.\n" > /dev/stderr fi @@ -61,6 +68,7 @@ DEFAULT_SCREENSHOT_DIRECTORY="\$HOME/Screenshots" # Default screenshot path PREFIX="screenshot-" # Screenshot prefix FORMAT="+%T_%D" # Screenshot format PREVIEW_IMAGE=true +PREFER_WAYSHOT=false IMAGE_SIZE="500" CACHE_IMAGE="false" CONFIG @@ -70,22 +78,31 @@ print_help() { cat << EOF screenshot-spmenu usage --t