1

I am trying achieve such behavior that screenshot is saved both to the disk and to clipboard. Been digging through these questions, but it's not coming together.

What is the terminal command to take a screenshot?
What is the command line equivalent of copying a file to clipboard?

Main problem being that I can't really copy the image to the clipboard to paste it with Ctrl+V.
Is there anything else I might want to consider ?

zx485
  • 2,865
George
  • 21

3 Answers3

2

You can just add the xclip command to scrot -e:

scrot '%F_%T.png' -e 'xclip -selection clip -t image/png "$f"; mv "$f" ~/Desktop/'

Of course you don't need to move the file to the Desktop, it's just an example how to combine multiple commands ...

You might need to install scrot:

sudo apt install scrot
pLumo
  • 27,991
1

Assuming you use the default Ubuntu desktop, just combine two options of the gnome-screenshot command for sending to the clipboard and to a file:

gnome-screenshot -c -f file.png

This will send the output to the clipboard and to a file, in this example in your Pictures folder, named according to the timestamp given by the date -Ins command.

vanadium
  • 97,564
1

I want to thank both @vanadium and @pLumo for their answers, which were very helpful, but both of used utilities have their own disadvantages and bugs at least on my system, so I finally went with combination of two approaches

#!/bin/bash

OUT_FILENAME=Screenshot from $(date "+%Y-%m-%d-%H-%M-%S").png OUT_PATH=~/Pictures/$OUT_FILENAME

gnome-screenshot -a -f $OUT_PATH xclip -sel clip < /dev/null xclip -selection clip -t image/png $OUT_PATH

George
  • 21