Fix some small issues with last commit
This commit is contained in:
parent
e0a2e9a240
commit
c9ffb8ef47
|
@ -8,6 +8,7 @@ IMAGE_SIZE="${IMAGE_SIZE:-500}"
|
||||||
CACHE_IMAGE="${CACHE_IMAGE:-false}"
|
CACHE_IMAGE="${CACHE_IMAGE:-false}"
|
||||||
SCREENSHOT_CONFIG_DIR="${SCREENSHOT_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/screenshot-spmenu}"
|
SCREENSHOT_CONFIG_DIR="${SCREENSHOT_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/screenshot-spmenu}"
|
||||||
SHOW_CURSOR="${SHOW_CURSOR:-true}"
|
SHOW_CURSOR="${SHOW_CURSOR:-true}"
|
||||||
|
PREFER_WAYSHOT="${PREFER_WAYSHOT:-false}"
|
||||||
DEFAULT_SCREENSHOT_DIRECTORY="${DEFAULT_SCREENSHOT_DIRECTORY:-$HOME/Screenshots}"
|
DEFAULT_SCREENSHOT_DIRECTORY="${DEFAULT_SCREENSHOT_DIRECTORY:-$HOME/Screenshots}"
|
||||||
FORMAT="${FORMAT:-+%T_%D}"
|
FORMAT="${FORMAT:-+%T_%D}"
|
||||||
PREFIX="${PREFIX:-screenshot-}"
|
PREFIX="${PREFIX:-screenshot-}"
|
||||||
|
@ -23,16 +24,22 @@ screenshot_take() {
|
||||||
[ "$2" = "true" ] && [ "$x11" != "true" ] && POS="$(slurp)"
|
[ "$2" = "true" ] && [ "$x11" != "true" ] && POS="$(slurp)"
|
||||||
|
|
||||||
if [ "$x11" = "true" ] && [ -x "$(command -v maim)" ]; then
|
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
|
[ "$3" = "true" ] && [ "$2" != "true" ] && cursor_arg=u
|
||||||
|
|
||||||
maim -s"${cursor_arg}"B > "$1" || exit 1
|
maim -"${sel_arg}""${cursor_arg}"B > "$1" || exit 1
|
||||||
elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v grim)" ]; then
|
elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v grim)" ] && [ "$PREFER_WAYSHOT" != "true" ]; then
|
||||||
[ "$2" = "true" ] && sel_arg="-g $POS"
|
if [ "$2" = "true" ]; then
|
||||||
grim "$sel_arg" - > "$1" || exit 1
|
grim -g "$POS" - > "$1" || exit 1
|
||||||
|
else
|
||||||
|
grim - > "$1" || exit 1
|
||||||
|
fi
|
||||||
elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v wayshot)" ]; then
|
elif [ -x "$(command -v slurp)" ] && [ -x "$(command -v wayshot)" ]; then
|
||||||
[ "$2" = "true" ] && sel_arg="-s $POS"
|
if [ "$2" = "true" ]; then
|
||||||
wayshot --stdout "$sel_arg" > "$1" || exit 1
|
wayshot --stdout -s "$POS" > "$1" || exit 1
|
||||||
|
else
|
||||||
|
wayshot --stdout > "$1" || exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
printf "Failed to take screenshot: Appropriate screenshot tools not found.\n" > /dev/stderr
|
printf "Failed to take screenshot: Appropriate screenshot tools not found.\n" > /dev/stderr
|
||||||
fi
|
fi
|
||||||
|
@ -61,6 +68,7 @@ DEFAULT_SCREENSHOT_DIRECTORY="\$HOME/Screenshots" # Default screenshot path
|
||||||
PREFIX="screenshot-" # Screenshot prefix
|
PREFIX="screenshot-" # Screenshot prefix
|
||||||
FORMAT="+%T_%D" # Screenshot format
|
FORMAT="+%T_%D" # Screenshot format
|
||||||
PREVIEW_IMAGE=true
|
PREVIEW_IMAGE=true
|
||||||
|
PREFER_WAYSHOT=false
|
||||||
IMAGE_SIZE="500"
|
IMAGE_SIZE="500"
|
||||||
CACHE_IMAGE="false"
|
CACHE_IMAGE="false"
|
||||||
CONFIG
|
CONFIG
|
||||||
|
@ -70,22 +78,31 @@ print_help() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
screenshot-spmenu usage
|
screenshot-spmenu usage
|
||||||
|
|
||||||
-t <time> Wait <time> seconds and then take the screenshot.
|
|
||||||
-f Take a full screen screenshot instead of selecting manually.
|
-f Take a full screen screenshot instead of selecting manually.
|
||||||
-s Take a screenshot, allowing the user to select a section manually.
|
-s Take a screenshot, allowing the user to select a section manually.
|
||||||
-t -f Wait <second argument> seconds and then take a full screen screenshot.
|
|
||||||
-h View this help screen.
|
-h View this help screen.
|
||||||
|
-t <num> In addition to -f or -s, passing -t <num> will wait <num> seconds before taking the screenshot.
|
||||||
|
|
||||||
No arguments will print this help.
|
No arguments will print this help.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
check_args() {
|
check_args() {
|
||||||
|
num=0
|
||||||
|
|
||||||
|
if [ "$2" = "-t" ] && [ -n "$3" ]; then
|
||||||
|
num=$3
|
||||||
|
|
||||||
|
[ -z "${num##*[!0-9]*}" ] && printf "You must specify a valid number.\n" > /dev/stderr && exit 1
|
||||||
|
elif [ -z "$3" ] && [ "$2" = "-t" ]; then
|
||||||
|
printf "You must specify a valid number.\n" > /dev/stderr && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# check arguments
|
# check arguments
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"") print_help; exit 0 ;;
|
"") print_help; exit 0 ;;
|
||||||
"-f") screenshot_take "/tmp/$PREFIX$DATE" "false" "$SHOW_CURSOR" "0" ;;
|
"-f") screenshot_take "/tmp/$PREFIX$DATE" "false" "$SHOW_CURSOR" "$num" ;;
|
||||||
"-s") screenshot_take "/tmp/$PREFIX$DATE" "true" "$SHOW_CURSOR" "0" ;;
|
"-s") screenshot_take "/tmp/$PREFIX$DATE" "true" "$SHOW_CURSOR" "$num" ;;
|
||||||
*) print_help; exit 0 ;;
|
*) print_help; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue