From 37864285aa5b1b2b5b71748e78b80a9926f08eeb Mon Sep 17 00:00:00 2001 From: Welnyr Date: Sun, 15 Sep 2024 16:26:42 +0500 Subject: [PATCH 1/2] added border and background color customizations --- hyprshot | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/hyprshot b/hyprshot index 0fb976f..f8a2bc1 100755 --- a/hyprshot +++ b/hyprshot @@ -27,6 +27,9 @@ Options: -r, --raw output raw image data to stdout -t, --notif-timeout notification timeout in milliseconds (default 5000) --clipboard-only copy screenshot to clipboard and don't save image in disk + --border-width width of the selection border in pixels (default 2) + --border-color color of the selection border (default #000000ff) + --background-color color around the selection (default #ffffff88) -- [command] open screenshot with a command of your choosing. e.g. hyprshot -m window -- mirage Modes: @@ -45,8 +48,8 @@ function Print() { if [ $DEBUG -eq 0 ]; then return 0 fi - - 1>&2 printf "$@" + + 1>&2 printf "$@" } function send_notification() { @@ -176,7 +179,7 @@ function begin_grab() { } function grab_output() { - slurp -or + slurp -or -b $BACKGROUND_COLOR -c $BORDER_COLOR } function grab_active_output() { @@ -196,7 +199,7 @@ function grab_selected_output() { } function grab_region() { - slurp -d + slurp -d -b $BACKGROUND_COLOR -c $BORDER_COLOR } function grab_window() { @@ -208,7 +211,7 @@ function grab_window() { # through stdin local boxes="$(echo $clients | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1]) \(.title)"' | cut -f1,2 -d' ')" Print "Boxes:\n%s\n" "$boxes" - slurp -r <<< "$boxes" + slurp -r -b $BACKGROUND_COLOR -c $BORDER_COLOR <<< "$boxes" } function grab_active_window() { @@ -236,7 +239,7 @@ function parse_mode() { } function args() { - local options=$(getopt -o hf:o:m:D:dszr:t: --long help,filename:,output-folder:,mode:,delay:,clipboard-only,debug,silent,freeze,raw,notif-timeout: -- "$@") + local options=$(getopt -o hf:o:m:D:dszr:t: --long help,filename:,output-folder:,mode:,delay:,clipboard-only,debug,silent,freeze,raw,notif-timeout:,border-color:,background-color: -- "$@") eval set -- "$options" while true; do @@ -280,6 +283,14 @@ function args() { shift; NOTIF_TIMEOUT=$1 ;; + --border-color) + shift; + BORDER_COLOR=$1 + ;; + --background-color) + shift; + BACKGROUND_COLOR=$1 + ;; --) shift # Skip -- argument COMMAND=${@:2} @@ -306,6 +317,9 @@ RAW=0 NOTIF_TIMEOUT=5000 CURRENT=0 FREEZE=0 +BORDER_COLOR=\#000000ff +BACKGROUND_COLOR=\#ffffff88 + [ -z "$XDG_PICTURES_DIR" ] && type xdg-user-dir &> /dev/null && XDG_PICTURES_DIR=$(xdg-user-dir PICTURES) FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')" [ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR} From c544817cccf3f194c32aef32e53b61398f2293dc Mon Sep 17 00:00:00 2001 From: Welnyr Date: Sun, 15 Sep 2024 21:16:52 +0500 Subject: [PATCH 2/2] added the border width option --- hyprshot | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hyprshot b/hyprshot index f8a2bc1..354f944 100755 --- a/hyprshot +++ b/hyprshot @@ -179,7 +179,7 @@ function begin_grab() { } function grab_output() { - slurp -or -b $BACKGROUND_COLOR -c $BORDER_COLOR + slurp -or -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH } function grab_active_output() { @@ -199,7 +199,7 @@ function grab_selected_output() { } function grab_region() { - slurp -d -b $BACKGROUND_COLOR -c $BORDER_COLOR + slurp -d -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH } function grab_window() { @@ -211,7 +211,7 @@ function grab_window() { # through stdin local boxes="$(echo $clients | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1]) \(.title)"' | cut -f1,2 -d' ')" Print "Boxes:\n%s\n" "$boxes" - slurp -r -b $BACKGROUND_COLOR -c $BORDER_COLOR <<< "$boxes" + slurp -r -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH <<< "$boxes" } function grab_active_window() { @@ -239,7 +239,7 @@ function parse_mode() { } function args() { - local options=$(getopt -o hf:o:m:D:dszr:t: --long help,filename:,output-folder:,mode:,delay:,clipboard-only,debug,silent,freeze,raw,notif-timeout:,border-color:,background-color: -- "$@") + local options=$(getopt -o hf:o:m:D:dszr:t: --long help,filename:,output-folder:,mode:,delay:,clipboard-only,debug,silent,freeze,raw,notif-timeout:,border-color:,background-color:,border-width: -- "$@") eval set -- "$options" while true; do @@ -291,6 +291,10 @@ function args() { shift; BACKGROUND_COLOR=$1 ;; + --border-width) + shift; + BORDER_WIDTH=$1 + ;; --) shift # Skip -- argument COMMAND=${@:2} @@ -319,6 +323,7 @@ CURRENT=0 FREEZE=0 BORDER_COLOR=\#000000ff BACKGROUND_COLOR=\#ffffff88 +BORDER_WIDTH=2 [ -z "$XDG_PICTURES_DIR" ] && type xdg-user-dir &> /dev/null && XDG_PICTURES_DIR=$(xdg-user-dir PICTURES) FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')"