Automated saving of area screenshots in Ubuntu

After taking 50 area screenshots from some document I found the save dialog that shows up every time quite annoying.
I wanted a functionality where:

  • By pressing a keyboard shortcut my mouse pointer turns into an area selection tool
  • The selection of an area begins by mouse press, ends when I release the mouse buttons
  • Screenshot is automatically saved to a file
  • No confirmation windows, no need to press any additional buttons

This led me to spending some time with gnome-screenshot and some other tools.

I’ve looked in keyboard shortcuts and still couldn’t find a solution. I’ve tried to use Shutter: which every time required me to confirm the screenshot and was slow. Then I’ve looked into gnome-screenshot -h and found that it allows to specify a filename within the command. This allowed me to later find the two solutions below:

Solution one

  1. Install and run CompizConfig Settings Manager (sudo apt-get install compizconfig-settings-manager)
    1. In commands window add as one of the command lines: gnome-screenshot –area –file=/home/tom/Pictures/$(date +%y-%m-%d-%H%M%S).jpg
      1. where „user” is your username. You can use any folder that you have a permission to save files. It will save each area screenshot and give it a filename that is the current date and time.
    2. Change to the Key Bindings tab, click on the button with the Disabled label that corresponds to your previously edited Command Line. Press the Grab key combination button and create a keyboard shortcut of your choice
    3. You should be able to take screenshots of an area by pressing the previously chosen keyboard shortcut, where screenshots are automatically saved (in the case of this example, in your Pictures folder).
    4. If the keyboard shortcut you choose doesn’t work, go to System Settings -> Keyboard -> Shortcuts and make sure that the keyboard shortcut isn’t already assigned to anything.

Solution two

  1. Go to your /usr/bin/ folder and make sure you have the permissions to save files there (https://websiteforstudents.com/enable-open-as-administrator-on-ubuntu-16-04-17-10-18-04/)
  2. Create a new text file, copy the code below into it and save it at /usr/bin/ (the path to it should be /usr/bin/filename)

  1. Right click on the created file, choose properties->permissions and check „Allow executing file as program”
  2. Now go to System Settings -> Keyboard -> Shortcuts -> Custom Shortcuts, press the „+” button to add a new shortcut
  3. Name the new screenshot however you like. Make sure the command name is the same as the filename you’ve created in the previous step
  4. Click on the Disabled label to the right of your newly created shortcut and assign a keyboard shortcut to it
  5. Try it out 🙂

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *