Нужна опция похожая на area с выделением области на экране и сохранением скрина но не в папку а в буфер обмена
xclip в помощь
#!/bin/bash
Check if the -help option is specified
if [ "1"="−help"];thenecho"Usage:0 [-win|-scr|-area|-tiff]"
echo " -win Take a screenshot of the selected window"
echo " -scr Take a screenshot of the entire screen"
echo " -area Take a screenshot of the selected area"
echo " -tiff Save screenshot in TIFF format"
exit 0
fi
Assistant
To modify the script to save the screenshot of a selected area directly to the clipboard instead of a file, you can use the xclip command. Install xclip if you don't have it:
sudo apt-get install xclip
Modify the script as follows:
#!/bin/bash
if [ "$1" = "-help" ]; then
echo "Usage: $0 [-win|-scr|-area|-tiff]"
echo " -win Take a screenshot of the selected window"
echo " -scr Take a screenshot of the entire screen"
echo " -area Take a screenshot of the selected area and save it to the clipboard"
echo " -tiff Save screenshot in TIFF format"
exit 0
fi
DIR="${HOME}/mh/screenshots"
DATE="$(date +%Y%m%d-%H%M%S)"
LOG="${DIR}/screenshots.log"
if [ ! -d "${DIR}" ]; then mkdir -p "${DIR}"; fi
if [ "$1" = "-win" ]; then
NAME="${DIR}/screenshot-${DATE}.png"
import -format png "${NAME}"
fi
if [ "$1" = "-scr" ]; then
NAME="${DIR}/screenshot-${DATE}.png"
import -format png -window root "${NAME}"
fi
# Screenshot a selected area and save it to the clipboard
if [ "$1" = "-area" ]; then
import -format png "png:-" | xclip -selection clipboard -t image/png
fi
if [ "$1" = "-tiff" ]; then
NAME="${DIR}/screenshot-${DATE}.tiff"
import -format tiff -window root "${NAME}"
fi
if [[ $# = 0 ]]; then
echo "No screenshot area has been specified. Screenshot not taken."
echo "${DATE}: No screenshot area has been defined. Screenshot not taken." >> "${LOG}"
else
echo "${NAME}" >> "${LOG}"
fi
Check if the dir to store the screenshots exists, else create it:
if [ ! -d "DIR"];thenmkdir−p"{DIR}"; fi
Screenshot a selected window
if [ "1"="−win"];thenNAME="{DIR}/screenshot-DATE.png"import−formatpng"{NAME}"
fi
Screenshot the entire screen
if [ "1"="−scr"];thenNAME="{DIR}/screenshot-DATE.png"import−formatpng−windowroot"{NAME}"
fi
Screenshot a selected area
if [ "1"="−area"];thenNAME="{DIR}/screenshot-DATE.png"import−formatpng"{NAME}"
fi
Save screenshot in TIFF format
if [ "1"="−tiff"];thenNAME="{DIR}/screenshot-DATE.tiff"import−formattiff−windowroot"{NAME}"
fi
if [[ # = 0 ]]; then
# Display a warning if no area defined
echo "No screenshot area has been specified. Screenshot not taken."
echo "{DATE}: No screenshot area has been defined. Screenshot not taken." >> "{LOG}"
else
# Save the screenshot in the directory and edit the log
echo "{NAME}" >> "${LOG}"
fi
Now when you run the script with the -area flag, it will save the selected area screenshot to the clipboard: