QubesOS Screenshot Clipboard Solution

After searching for this for like ever, I wanted to ask here, if someone has a permanent, relatively simple solution to the Clipboard Problem with Screenshots.

On Qubes R4.2.4 I cannot get the Screenshot Application to work at all. Only thing that works is Saving the screenshot in dom0, which I don’t really like. There IS a option to copy it to the clipboard, but I’ve never seen it actually work. Is there some workaround for this? It would surely be more convenient to just copy the image to the system wide clipboard and then paste it in a particular qube, then always having to move the image file from dom0 to a qube and so on.

Thanks

AFAIK the Qubes Global Clipboard is text-only.

What I do, and consider “easy” is:

  1. take a screenshot with [Alt-] PrtSc
  2. save it in dom0 (by default in the ~/Pictures directory)
  3. in dom0, to move the file, say “test.png”, to the qube “personal”, for example, I run:
    cat Pictures/test.png | qvm-run --pass-io personal -- 'cat > Pictures/test.png'
  4. edit/process the file in the “personal” qube…

As I don’t do this very often, I did not wrap it up in a script… but it’s trivial to do so (together with some sanity checks).

3 Likes

And… welcome to this Forum!

2 Likes

There’s a contrib package - look at the README
here
: you could leverage that to ape a global clipboard, since I believe it
has the possibility to copy to clipboard in a qube.

In general I dont like copying anything from dom0 to the global
clipboard, and much prefer having to specify the target. That’s me.

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

2 Likes

Thank you!

2 Likes

Just to be clear: the screenshot application in dom0 is xfce4-screenshooter, the default screenshot application of XFCE.

And if you only want to take and use a screenshot in the same qube, you can use xfce4-screenshooter inside this specific qube.

1 Like

I often take screenshots and need to place them in various AppVMs. I automated this with a simple script. How it works:

  1. I press PrintScreen
  2. I select the area for which I want to take a screenshot
  3. A menu of currently running VMs appears (excluding e.g. templates or vaults)
  4. I select the target AppVM and click OK

The screenshot file is copied to the selected AppVM, and I can find the file itself in /home/user/QubesIncoming/name.png

How to do it?

  1. Check or install missing software: zenity and xfce4-screenshooter
sudo qubes-dom0-update xfce4-screenshooter
sudo qubes-dom0-update zenity
  1. Execute the commands to create the directory structure and place the previously mentioned script in $HOME/.local/bin/custom-screenshooter
# Run on dom0 as USER
mkdir -p $HOME/.local/bin
cat <<EOF > $HOME/.local/bin/custom-screenshooter
#!/bin/bash

screenshot_file="$HOME/Pictures/Screenshot_$(date +%F_%H-%M-%S).png"
xfce4-screenshooter -r -s "$screenshot_file"
if [[ -f "$screenshot_file" ]]
then
  vms=$(qvm-ls --running --raw-list --fields NAME |grep -vE '^(dom0$)|(debian|default|fedora|sys)-|vault$')
  target_vm=$( echo "$vms" | zenity --list --title="Copy to vm" --column="VM" --height=400 --width=300)
  if [[ -z "$target_vm" ]]
  then
    exit 1
  fi
  qvm-copy-to-vm "$target_vm" "$screenshot_file"
fi

EOF
chmod 700 $HOME/.local/bin/custom-screenshooter

As we know, you can’t copy to dom0 from the clipboard.So how do you copy this script? Copy it to a file in any AppVM and on dom0 copy the contents of the file to dom0:

qvm-run --pass-io YOUR_APPVM "cat /home/user/path/to/this/file.txt" > file.txt
  1. Set the keyboard shortcut. Qubes Application Menu → Settings Icon → Keyboard → Application Shortcuts → Add. In the ‘command’ field type /home/youruser/.local/bin/custom-screenshooter and select the key (e.g. PrintScreen).

Notes:

  • I use xfce4-screenshooter, although another one (e.g. built into kde Spectacle) is better. By better I mean that it allows more functionality, e.g. the ability to edit the screen, such as selecting something on it, simple cropping, etc. The tool is cool, but when I saw how many dependencies it requires - I gave up.
  • I think that such a solution (of course in a more advanced form) could be a nice feature for default qubes OS installations as, for example, a screenshooter configuration option, although it would probably be necessary to carefully consider how to implement it in a safe way.
3 Likes

This is a very convenient and good solution. Thanks a lot! I’ll look into this asap.