From 0b328fb64d5cddd128e8ac4c1b5a29f7623fa1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Fri, 20 Sep 2024 14:53:22 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(hypr):=20add=20new=20hyprshot?= =?UTF-8?q?=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit code extracted from https://github.com/Gustash/Hyprshot/pull/68 --- .config/hypr/scripts/hyprshot | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.config/hypr/scripts/hyprshot b/.config/hypr/scripts/hyprshot index c99e6d5b..288f663a 100755 --- a/.config/hypr/scripts/hyprshot +++ b/.config/hypr/scripts/hyprshot @@ -26,6 +26,9 @@ Options: -s, --silent don't send notification when screenshot is saved -r, --raw output raw image data to stdout -t, --notif-timeout notification timeout in milliseconds (default 5000) + --border-width width of the selection border in pixels (default 0) + --border-color color of the selection border (default #181926) + --background-color color around the selection (default #8087a25a) --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 @@ -150,6 +153,7 @@ function checkRunning() { function begin_grab() { if [ $FREEZE -eq 1 ] && [ "$(command -v "hyprpicker")" ] >/dev/null 2>&1; then + sleep 0.2 hyprpicker -r -z & sleep 0.2 HYPRPICKER_PID=$! @@ -204,7 +208,7 @@ function grab_selected_output() { } function grab_region() { - slurp -d + slurp -d -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH } function grab_window() { @@ -216,7 +220,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 -w $BORDER_WIDTH <<<"$boxes" } function grab_active_window() { @@ -244,7 +248,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:,border-width: -- "$@") eval set -- "$options" while true; do @@ -288,6 +292,18 @@ function args() { shift NOTIF_TIMEOUT=$1 ;; + --border-color) + shift + BORDER_COLOR=$1 + ;; + --background-color) + shift + BACKGROUND_COLOR=$1 + ;; + --border-width) + shift + BORDER_WIDTH=$1 + ;; --) shift # Skip -- argument COMMAND=${@:2} @@ -315,6 +331,9 @@ RAW=0 NOTIF_TIMEOUT=5000 CURRENT=0 FREEZE=0 +BORDER_COLOR=\#181926 +BACKGROUND_COLOR=\#8087a25a +BORDER_WIDTH=0 [ -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}