1

I used to use "Gadwin print screen" on Windows where I could just press a shortcut and a predefined screen area would get saved to a folder (no questions asked), which is very helpful while doing lengthy online courses .

I have switched to Ubuntu and I need an alternative. I have installed Shutter and managed to create a shortcut that can trigger the "selection" tool and auto save the picture, but the problem is I need to re-position the predefined selection area (which is positioned on lower right of screen by default), and shutter doesn't remember the previous position, which is time consuming in my usage scenario where hundreds of screen shots are taken.

b_laoshi
  • 4,868
  • 4
  • 26
  • 49
dipu
  • 79
  • 1
  • 8

1 Answers1

3

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).

b_laoshi
  • 4,868
  • 4
  • 26
  • 49