diff --git a/hyprshot b/hyprshot index 38913a5..343b037 100755 --- a/hyprshot +++ b/hyprshot @@ -19,6 +19,7 @@ Options: -f, --filename the file name of the resulting screenshot -d, --debug print debug information -s, --silent don't send notification when screenshot is saved + -r, --raw output raw image data to stdout --clipboard-only copy screenshot to clipboard and don't save image in disk -- [command] open screenshot with a command of your choosing. e.g. hyprshot -m window -- mirage @@ -50,23 +51,32 @@ function send_notification() { -i "${1}" -a Hyprshot } +function trim() { + convert "${1}" -trim +repage "${1}" +} + function save_geometry() { Print "Geometry: %s\n" "${1}" local output="" + if [ $RAW -eq 1 ]; then + grim -g "${1}" - | trim - + return 0 + fi + if [ $CLIPBOARD -eq 0 ]; then mkdir -p "$SAVEDIR" grim -g "${1}" "$SAVE_FULLPATH" output="$SAVE_FULLPATH" # Trim transparent pixels, in case the window was floating and partially # outside the monitor - convert $output -trim +repage $output + trim "${output}" wl-copy < "$output" [ -z "$COMMAND" ] || { "$COMMAND" "$output" } else - wl-copy < <(grim -g "${1}" - | convert - -trim +repage -) + wl-copy < <(grim -g "${1}" - | trim -) fi send_notification $output @@ -109,7 +119,7 @@ function grab_window() { } function args() { - local options=$(getopt -o hf:o:m:ds --long help,filename:,output-folder:,mode:,clipboard-only,debug,silent -- "$@") + local options=$(getopt -o hf:o:m:dsr --long help,filename:,output-folder:,mode:,clipboard-only,debug,silent,raw -- "$@") eval set -- "$options" while true; do @@ -139,6 +149,9 @@ function args() { -s | --silent) SILENT=1 ;; + -r | --raw) + RAW=1 + ;; --) shift # Skip -- argument COMMAND=${@:2} @@ -161,6 +174,7 @@ fi CLIPBOARD=0 DEBUG=0 SILENT=0 +RAW=0 FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')" [ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR}