Bind a script that implements scrot and imagemagick to a keyboard shortcut
1) Install the necessary applications
From the command line, run:
sudo apt install scrot imagemagick
2) Create the script
Open your text editor of choice and create a new plaintext file with the following contents. Be sure the modify the variables at the top to specify where you want the images saved and what portion of the screen you want to crop out. See this trick for getting mouse coordinates which can be used to find left
and top
and to calculate width
and height
.
#!/bin/bash
Change these values to match your preferences
imageQuality=100 # scrot default is 75
screenshotDir="/tmp"
imageName="$(date +%Y-%m-%d.%H:%M:%S.%N).jpg" # save image names as timestamp
left=10 # begin crop this number of pixels from the left of the image
top=10 # begin crop this number of pixels from the top of the image
width=100 # crop this many pixels wide
height=100 # crop this many pixels tall
#Do not make any more changes from here down unless you know what you're doing
imagePath="$screenshotDir/$imageName"
scrot -q $imageQuality "$imagePath"
convert "$imagePath" -crop ${width}x${height}+${left}+${top} "$imagePath"
Save this script wherever you like and make it executable. Assuming you named your script screenshot.sh
, you would do this at the command line like so:
chmod +x /path/to/your/script/screenshot.sh
3) Bind this script to a keyboard shortcut
Follow the directions found here to create a custom keyboard shortcut. When you get to the point where you're supposed to enter the command, put the complete path to your screenshot.sh
file (including the filename).