This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Spectacle - Save a screenshot to clipboard without the GUI

Tags: None
(comma "," separated)
yu3ib7TgK9i
Registered Member
Posts
7
Karma
0
Hi,

I would like to be able to take a screenshot and save it to clipboard, similarly as in Windows, without a GUI window appearing. Additionally, it seems that if I do click "copy to clipboard" in the GUI, closing or discarding (maybe only discarding) will also discard the clipboard image contents. However, I would rather the GUI not show at all.

Is this a possible setting?

Thank you.
lueck
Mentor
Posts
225
Karma
2
yu3ib7TgK9i
Registered Member
Posts
7
Karma
0
lueck wrote:https://docs.kde.org/trunk5/en/kdegraphics/spectacle/starting.html


Sorry, but I've already tried all of Spectacle's options. I cannot set the default 'save location' to the clipboard - only a folder, without spectacle's GUI.

I want to save the image to clipboard, not the file location.
shalak
Registered Member
Posts
2
Karma
0
OS
yu3ib7TgK9i wrote:
lueck wrote:https://docs.kde.org/trunk5/en/kdegraphics/spectacle/starting.html


Sorry, but I've already tried all of Spectacle's options. I cannot set the default 'save location' to the clipboard - only a folder, without spectacle's GUI.

I want to save the image to clipboard, not the file location.


Huh, ever since I found out that FB messanger allows to paste raw image into conversation I started to look for some solution.

I worked around the lack of this option in the following way:

0. sudo apt-get install xclip
1. Configure spectacle to use Rectangular Selection, default save to /some/path/Screenshot_%Y%M%D_%H%m%S
2. Configure PrintScreen for rectangular selection via custom shortcuts
3. Try it - once you select the area and hit enter it should show the pop-up notification about saved file.
4. On this notification select the settings button
5. In the notification settings enable "Run command" and set it as /usr/bin/xclip -selection clipboard -target image/png -i $(ls -1tr /some/path/Screenshot_*.png | tail -n 1)

You could set the screenshot paths to use /tmp, so it's cleared regularly.

Enjoy :)
GeorgeM
Registered Member
Posts
3
Karma
0
shalak wrote:
5. In the notification settings enable "Run command" and set it as /usr/bin/xclip -selection clipboard -target image/png -i $(ls -1tr /some/path/Screenshot_*.png | tail -n 1)

You could set the screenshot paths to use /tmp, so it's cleared regularly.



You must do this every time when you make a screenshot?
I'm joining the question about screenshoting to clipboard without popup window of Spectacle, by default, without any question ....
gnome-screenshot can do it perfectly, but only in GNOME session. In KDE it doesn't work too.
Shai
Registered Member
Posts
2
Karma
0
OS
I'm also interested in a solution for this.
lueck
Mentor
Posts
225
Karma
2
since 19.04.0 Spectacle has a new commandline option:

-c, --clipboard In background mode, copy screenshot to clipboard

see https://cgit.kde.org/spectacle.git/comm ... d47ed70b28

spectacle -bcn will capture the entire desktop and copy the screenshot without gui and notification to the clipboard

use the options f, m, a, u, r to specify what to capture
lpryszcz
Registered Member
Posts
1
Karma
0
Building on previous answers, you could:
- enter Settings > Shortcuts > Custom Shortcuts
- create new custom group ie "Spectacle": Edit > New Group
- and create new custom shortcut(s): Edit > New > Global Shortcut > Command/URL
- fill the name ie "PrintScreen Clipboard Rectangular"
- Trigger: Ctrl+Shift+Print
- Command/URL: spectacle -bcr
- Apply

Now pressing Ctrl+Shift+Print will trigger rectangular printscreen that will be saved directly to clipboard after pressing Enter. You can see all spectacle commands using `spactacle --help`.
Note, in order to copy print-screens to clipboard in the background, you should use `-bc`.

This will allow you to create Gnome-like print-screen behaviour in KDE5 :)
Hope someone will find it useful!
Param35h
Registered Member
Posts
1
Karma
0
Wow, fantastic @lpryszcz, worked perfectly, thank you!
visone
Registered Member
Posts
32
Karma
0
OS
Hi!
You can set a shortcut for that from settings/shorcuts/spectacle
hammad
Registered Member
Posts
3
Karma
0
spectacle -c returns "Unknown option 'c'.", please help
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS
Read again, it explicitly says that the option -c only works in background mode, so you need to use -bc


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...
DarkMac
Registered Member
Posts
3
Karma
0
Just logged in to say a big thank you !!!
Using rectangular screenshot copied to clipboard directly a lot. So it ease my work a lot.


Thank you again!
User avatar
dandv
Registered Member
Posts
28
Karma
0
OS

Why isn't this default?!

Fri Feb 12, 2021 2:23 pm
lpryszcz wrote:Building on previous answers, you could:
- enter Settings > Shortcuts > Custom Shortcuts
- create new custom group ie "Spectacle": Edit > New Group
- and create new custom shortcut(s): Edit > New > Global Shortcut > Command/URL
- fill the name, e.g. "Area screenshot"
- Trigger: Shift+Print
- Command/URL: spectacle -bcr
- Apply


One more step here, make sure to check the checkbox next to that new shortcut.

As to why copying to the clipboard isn't easily configurable in the Spectable UI, or even the default, beats me. A lot of tools accept pasting images from clipboard (browser apps, image editors etc.), and usually you want to annotate the screenshot somehow, and name is something meaningful instead of ScreenshotXXX, so saving to disk is rarely what you want.
User avatar
lvxejay
Registered Member
Posts
1
Karma
0
OS

Re: Why isn't this default?!

Thu Apr 29, 2021 10:55 pm
dandv wrote:
lpryszcz wrote:Building on previous answers, you could:
- enter Settings > Shortcuts > Custom Shortcuts
- create new custom group ie "Spectacle": Edit > New Group
- and create new custom shortcut(s): Edit > New > Global Shortcut > Command/URL
- fill the name, e.g. "Area screenshot"
- Trigger: Shift+Print
- Command/URL: spectacle -bcr
- Apply


One more step here, make sure to check the checkbox next to that new shortcut.

As to why copying to the clipboard isn't easily configurable in the Spectable UI, or even the default, beats me. A lot of tools accept pasting images from clipboard (browser apps, image editors etc.), and usually you want to annotate the screenshot somehow, and name is something meaningful instead of ScreenshotXXX, so saving to disk is rarely what you want.


I really wanted the ability to do a rectangular region capture, and then simultaneously copy it to the clipboard while also saving it to a file. Adjust the Command/URL added to the Custom Shortcut with the command below. Remember to change the saved image path to something meaningful for your environment.
Code: Select all
spectacle -brc -o "$HOME/pictures/screenshots/Screenshot_$(date +'%Y%m%d_%H%M%S').png"


Image


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]