📜 ⬆️ ⬇️

Universal way to quickly take a screenshot in linux

How did it come to life


With the transition of ubuntu to unity, enlightenment and a thirst for something that would not have to be redone from scratch once in half a year has somehow come abruptly. I set myself arch, and there it came to minimalism and affection for xfce.

True, my laziness was still not so developed then and the screenshots were made with the help of GIMP.
For details - please under the cat.

Time passed ...

And I'm sick of this tedious thing. I decided to automate the taking of screenshots and, after a little digging, found that the favorite console image editor ImageMagick does this work for once:
import -window root $filename.png #    ,   

And we have a snapshot of the entire screen. Hang on any combination of keys will not be problems
')
Let's go further. If done:
 import $filename.png 

This selection (or selected window) is saved as the same file. True, the trouble is that the window is saved without a frame. Adding the "-frame" key fixes this.

Well, a small script has already formed, which saves a screenshot with the date:
 #!/bin/bash case $1 in full) import -window root ~/Images/Screenshots/screen_$(date +%F_%H-%M-%S).png ;; window) import -frame ~/Images/Screenshots/screen_$(date +%F_%H-%M-%S)_window.png ;; esac 

It can be hung on different keyboard shortcuts and take screenshots of the entire screen, or a selected area / window.
You can stop at this ...

But Laziness whispered: "Go on, there is always something that can be improved."

So it happened. After all, you can immediately put screenshots directly into the cloud:
 #!/bin/bash case $1 in full) import -window root ~/Dropbox/Public/Screenshots/screen_$(date +%F_%H-%M-%S).png ;; window) import -frame ~/Dropbox/Public/Screenshots/screen_$(date +%F_%H-%M-%S)_window.png ;; esac 

Soul rejoiced. But, if it is immediately in the cloud, you can go ahead and immediately receive a link to the public. This will help utility xclip, which works with the clipboard and the CLI interface for dropbox. As a result, it turns out such a thing:
 #!/bin/bash case $1 in full) name=~/Dropbox/Public/Screenshots/screen_$(date +%F_%H-%M-%S).png import -window root $name dropbox puburl $name | xclip -i;; window) name=~/Dropbox/Public/Screenshots/screen_$(date +%F_%H-%M-%S)_window.png import -frame $name dropbox puburl $name | xclip -i;; esac 

We have in the primary buffer a link to the newly created file.
Here, by the way, and he (true, shifted to another place)
screenshot
The fact that this is done with the help of imagemagick allows you to get up with a screenshot anything you want, up to scale change, compression to the required quality, and so on. Everyone gets out of his way as best he can, and the tool allows.
But the fact that this script is needed, it performs at 100%. I hope many will help.

Source: https://habr.com/ru/post/203972/


All Articles