📜 ⬆️ ⬇️

Share screenshots on the Internet

Often, when communicating on the Internet, it is necessary to quickly show the other person a screenshot (program window) to help him cope with a problem or solve his problem.
To do this, you can go a long way - save the snapshot to a file, go to the appropriate hosting, upload the result, and give the link to the other person. But you can maximally simplify your life by once writing a simple script that will do all the routine work.



Since I use KDE, I use the following utilities for my own purposes:
xsnap - for the screenshot itself (option - scrot);
uimge - to fill the image on the hosting;
kdialog - for displaying windows and notifications (standard KDE utility, options - xdialog, gtkdialog);
klipper - to place a link to the clipboard (standard KDE utility, variants - glipper).
')
All the action ultimately boils down to calling the script with a hot key (you can customize with your DE), select a section of the screen (or click on the desired window) and select the desired hosting from the list. As a result, a ready link appears in the clipboard.

#!/bin/sh
rm -f /tmp/xsnap.png
xsnap -fn -misc-*-*-*-*-*-*-*-*-*-*-*-*-* -png -file /tmp/xsnap.png
hosting=$(kdialog --title Uimge --menu " :" \
savepic "savepic.ru" \
funkyimg "funkyimg.com" \
smages "smages.com" \
radikal "radikal.ru" \
opicture "opicture.ru" \
ipicture "ipicture.ru" \
upimg "upimg.ru" \
piccy "piccy.info" \
picamatic "picamatic.com" \
keep4u "keep4u.ru" \
4picture "4picture.ru" )
url=$(/usr/bin/uimge --${hosting} /tmp/xsnap.png 2> /dev/ null )
if [ "${url}" != "" ]
then qdbus org.kde.klipper /klipper org.kde.klipper.klipper.setClipboardContents "${url}"
kdialog --passivepopup " "
else kdialog --sorry " "
fi

* This source code was highlighted with Source Code Highlighter .

The main volume of work is performed by the utility uimge, about which they already wrote on Habré, which is a python script. Download (including the Windows version) can be on the home page , there is also an assembly file ( ebuild ) for Gentoo Linux.

Everything else is for beauty and convenience.





This was my first topic on Habré.

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


All Articles