From 49aaa26a64c3e7b2f53fd3edb4c1c16fe4025fb1 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Tue, 1 Dec 2020 20:54:28 +0100 Subject: [PATCH] Flameshot content directly send to clipboard --- printscreen | 13 +++++++++++-- screen.to.0x0 | 26 ++++++++++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/printscreen b/printscreen index 5b60fee..a37feb2 100755 --- a/printscreen +++ b/printscreen @@ -130,19 +130,28 @@ fi ## Use Flameshot if available {{{ if [ "$(command -v flameshot)" ]; then + ### Take a capture {{{ + ### --raw : To prevent flameshot from returing immediately + ### --path : Default path to store saved image + ### --delay : Wait XX milliseconds before launching flameshot + ### And immediately send PNG raw to clipboard if [ "${DELAYED_MODE}" -eq "0" ]; then debug_message "Flameshot tool − \ DELAYED_MODE enabled." ## Convert delay screenshot to milliseconds delay_screenshot="$(( ${delay_screenshot} * 1000 ))" ## Open flameshot after "${delay_screenshot}" seconds - flameshot gui --path /tmp --delay "${delay_screenshot}" + flameshot gui --raw --path /tmp --delay "${delay_screenshot}" | xclip -selection clipboard -t image/png else debug_message "Flameshot tool − \ Capture with gui." ## Open flameshot - flameshot gui --path /tmp --delay 50 + flameshot gui --raw --path /tmp --delay 50 | xclip -selection clipboard -t image/png fi + ### }}} + ### Store the clipboard content to a new image file + xclip -out -selection clipboard -t image/png > /tmp/$(date +%Y%m%d-%H%M%S)."${PROGNAME}".png + ## }}} else ## Use Scrot {{{ debug_message "Scrot tool − \ diff --git a/screen.to.0x0 b/screen.to.0x0 index 7d7bfc3..a26254b 100755 --- a/screen.to.0x0 +++ b/screen.to.0x0 @@ -135,33 +135,31 @@ fi ## Use Flameshot if available {{{ if [ "$(command -v flameshot)" ]; then ### Take a capture {{{ + ### --raw : To prevent flameshot from returing immediately + ### --path : Default path to store saved image + ### --delay : Wait XX milliseconds before launching flameshot + ### And immediately send PNG raw to clipboard if [ "${DELAYED_MODE}" -eq "0" ]; then debug_message "Flameshot tool − \ DELAYED_MODE enabled." ## Convert delay screenshot to milliseconds delay_screenshot="$(( ${delay_screenshot} * 1000 ))" ## Open flameshot after "${delay_screenshot}" seconds - flameshot gui --path /tmp --delay "${delay_screenshot}" + flameshot gui --raw --path /tmp --delay "${delay_screenshot}" | xclip -selection clipboard -t image/png else debug_message "Flameshot tool − \ Capture with gui." ## Open flameshot - flameshot gui --path /tmp --delay 50 + flameshot gui --raw --path /tmp --delay 50 | xclip -selection clipboard -t image/png fi ### }}} - ### Get full path of the image file of the capture - ### If the capture was successfully saved - if find /tmp -maxdepth 1 -mmin -1 -iname "*.png" > /dev/null 2>&1; then - ### Get the absolut path of the most recent image - img_absolut_path="$(find /tmp -maxdepth 1 -mmin -1 -iname "*.png" | sort | tail -n 1)" - debug_message "Flameshot tool − \ -Absolut path of the most recent image in /tmp: ${img_absolut_path}." - else - debug_message "Flameshot tool − \ -No recent image in /tmp." - fi - echo "${img_absolut_path}" | xclip -rmlastnl -selection clipboard + ### Store the clipboard content to a new image file + xclip -out -selection clipboard -t image/png > /tmp/$(date +%Y%m%d-%H%M%S)."${PROGNAME}".png + + ### Store the absolut path of the new image file to clipboard + echo "/tmp/$(date +%Y%m%d-%H%M%S).${PROGNAME}.png" | xclip -rmlastnl -selection clipboard + ## }}} else ## Use Scrot {{{ debug_message "Scrot tool − \