Screenshot tool for Qubes OS


Making and sharing screenshots in Qubes OS is one of the main hurdles in migrating from a traditional operating system. There are few tools made by different contributors for this but none were working in the simple way I was used to (upload to specific image host and copy to clipboard).

The following script is designed to allow for the capturing of a screenshot by selecting a region with your mouse and then uploading it to (you can easily change the image host, we use as the images are not indexable and it has no ads).

The tool requires scrot, so install it by running in a dom0 terminal:

sudo qubes-dom0-update scrot

And xclip in the templates, so open up the template and run for Fedora:

sudo dnf install xclip

Or for Debian:

sudo apt install xclip

Shutdown the templates and restart any Qubes based on those templates.

Then create a new file /usr/local/bin/screenshot and add inside:

sleep 0.2

scrot -s -b ~/$SCRID.png || break
SCR=`cat ~/$SCRID.png|qvm-run --pass-io $1 "curl -s -X POST -F 'img=@-'  ''"`
rm ~/$SCRID.png

if [ -z "$SCR"] || [$SCR == "fail"]; then 
	zenity --notification --text "Could not upload the screenshot"
	exit 0

qvm-run $1 "echo '$SCR'|xclip -selection clipboard"
zenity --notification --text "Screenshot uploaded successfully - $SCR"

Afterwards, open System Tools -> Keyboard -> Application shortcuts and add a new shortcut towards: /usr/local/bin/screenshot domain, where domain is the AppVM/Qube where the image url should be added to the clipboard. This can be a communication Qube, where your chat/email clients are running. Use the PrtScr button as hotkey or any other combination you wish.

If you wish to copy the url in the clipboard of multiple Qubes, simply add multiple lines of the following code at the end of the script:

qvm-run other-cube "echo '$SCR'|xclip -selection clipboard"

Recent Posts