How to copy area screenshot to clipboard on Kubuntu 18.04?

You can take a screenshot from a selected area in Kubuntu with Shift+PrtScr. The only problem is that this saves the image to ~/Pictures by default so you have to open ~/Pictures in your file manager and then copy/paste or drag and drop the image into the desired application.

In Ubuntu you have the ability to press Ctrl+Shift+PrtScr to copy to the clipboard. Is there a way to do this in Kubuntu 18.04? I checked the default available shortcuts in System Settings > Shortcuts but I did not find shortcuts similar to the ones Ubuntu has.


Solution 1:

tl;dr

Just create a shortcut for spectacle -rbc.

Explanation

Kubuntu uses Spectacle for screenshots. If you run spectacle -h you can see all the options it supports. We need these options:

-r, --region        Capture a rectangular region of the screen
-b, --background    Take a screenshot and exit without showing the GUI
-c, --clipboard     In background mode, copy screenshot to clipboard

So just create a shortcut for spectacle -rbc. If you prefer the GUI to popup, then create a shortcut for spectacle -r. In GUI mode you still have a button that copies the capture to the clipboard and Ctrl+C works too!

Tutorial

  1. Launch Custom Shortcuts by one of these ways:
  • Press Alt+Space and search for "Custom Shortcuts".
  • Open the start menu (Super) and search for "Custom Shortcuts".
  • Open the start menu (Super) and launch Settings > System Settings then go to Workspace > Shortcuts > Custom Shortcuts.
  1. Select "Screenshots" (if it doesn't exist create it under Edit > New Group) then Click Edit > New > Global Shortcut > Command/URL.
  2. Name it and give it a comment like "Take Rectangular Region Screenshot".
  3. Set the shortcut in the "Trigger" tab to Shift+PrtScr, Ctrl+Shift+PrtScr or whatever you want.
  4. In the "Action" tab paste the command: spectacle -rbc or spectacle -r for the GUI version. Custom Shortcuts setting shortcut action to command
  5. Press "Apply" and you are ready to use your shortcut.

You can do the same for "Take Active Window Screenshot" just use the command spectacle -abc.

Usage

After pressing the shortcut, you can do your rectangular selection by clicking and dragging, then take the screenshot with Enter or by double clicking the selected area. There are other actions you can do at this stage that will be displayed at the bottom of the monitor:

Taking a screenshot

After taking the screenshot with spectacle -rbc a notification will be shown saying that "a screenshow was saved to your clipboard". With spectacle -r Spectacle will open and you can use its buttons or Ctrl + C.

Spectacle captured area in rectangle mode