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.
save it in dom0 (by default in the ~/Pictures directory)
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'
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).
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.
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:
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.
Just saw this thread and had a better idea, bcs I also always found this annoying (having to copy the screenshot from dom0) - if you install xfce4-screenshotter in every VM you use (in their templates), then you can use this inside the VM you want to screenshot. You could have a i3wm keybind for this that runs a script in dom0 which in turn runs this command inside the currently focused VM.
Not sure how to do this in xfce4, but I assume its possible.
Will never work. The screen is rendered in dom0 only. Each VM cannot even see it’s own windows. Prevents any screensharing for video chat apps, and also screenshots from within the VM. Which is why only dom0 has the ability to screenshot anything.
This script method automates the moving of the image file, so it won’t leave clutter and no need to manually copy files. Using qubes built in tools to move the file and the raw image to the app-vm filesystem and clipboard respectively.
This is the debian-13-minimal template + the qubes apt packages that are required for networking + chromium browser via apt, nothing else. Oh and xfce4-screenshotter and feh via apt ofc.
PS: Even with your method, if you run i3wm you could detect which window your screenshotting and automatically move it to the respective VM - I didnt read the script, but I assume you have to enter that somehow (no idea if xfce4 can do that too somehow).
Here is the result (from another VM though, but I tried this with a few VMs and it works reliably)
Oh, that indeed works. Maybe I got it wrong or it used to be that way.
One drawback to your method seems to be that when trying to mouse drag a region (rather than active window or entire screen), it does not preview the outline of the box. Not that big of a deal.
One benefit of my method is the ability to capture screenshots across VMs, which is a feature somewhat like the global clipboard.
Correct, yes. I was thinking the same before, as in is that a bug or a feature, as in it can communicate to hacked VM a whats going on in not-hacked VM b.
But for sharing screenshots, that might be desired (provided one assumes that a and b are not hacked xD which one may assume at most times I assume lol).
That xprop and auto-copy solution is nifty though, I will put this into my system I think.. maybe via i3wm sth like windows + s == screenshot inside vm, windows + shift + s == windows via dom0 + copy via xprop window detection.
I had missed the previous mention last year by parulin that xfce4-screenshooter works in each VM. Thanks for reminding this thread that it does work.
Yeah, that’s a valid concern for Qubes users.
I think that since these scripted implementations are specific enough and only ever use “region” and never “entire screen”… there is no risk of accidentally sending anything that the user doesn’t explicitly select. And since this is only triggerable from dom0, then the whole system (dom0) would have to be compromised to automatically run and select a region of the screen.
So it’s very similar to global clipboard, which requires user action to copy and paste.
Although.. looking again at xfce4-screenshooter being in the app-vm…
It’s easy to set up a Custom Action `qvm-copy %f` that will bring up the standard dialog to copy it. Of course after that, it’ll be manual steps to copy that image into the clipboard of the target vm.
So xfce4-screenshooter being in each app-vm, is very simple, and no scripts. But for a keyboard shortcut to run it with the -r and -c arguments, there might a need have a script in dom0. In that case, it’ll need to get the active window to know which VMNAME to run it in.
So my method only has the benefit of being global to take screenshots across any VM, and being able to see the preview of the region you are selecting.