On Saturday, February 17, 2018 at 11:11:40 PM UTC+1, [799] wrote:
> Hello,
> having the idea of a qvm-screenshot-to-clipboard script I was eager to try 
> writting a script.
> The solution I had in mind could work but I am struggling with a small issue 
> and would like to get some help.
> The script takes a screenshot in dom0, store it to a file and qvm-copy the 
> file to the target appvm (one and only command line argument for the script).
> Then within the AppVM it is using xclip to copy the graphic to clipboard and 
> removes all temporary files in the AppVM and dom0
> All pieces are working, except the xclip command when launced from dom0.
> When I launch the command within the AppVM it is working.
> But I need to start the xclip command from an external script and when I do 
> so, the same command is not working.
> It seems that I am missing something when using xclip via script which is run 
> in a new terminal session (from dom0 but also within the App)
> Any ideas how to fix this?
> It feels so frustrating that I nearly have a working solution but I am 
> missing the last few meters.
> How to use the script:
> 1) in dom0: launch script
> 2) make the screenshot by selection the area
> as the xclip is not working in the AppVM as supposed:
> 3) switch to the AppVM where the screenshot should be used
> 4) launch the "helper script" in the AppVM which is running the following 
> command 
> xclip -selection clipboard -t image/png 
> /home/user/QubesIncoming/dom0/qvm-screenshot-to-clipboard.png
> My qvm-screenshot-to-clipboard script which has to be placed and run from 
> dom0:
> --- BEGIN of script ---
> #!/bin/bash
> # qvm-screenshot-to-clipboard
> # Creates a dom0 screenshot and copy it to the Clipboard of an AppVM
> MyAppVM=$1
> MyScreenshot=qvm-screenshot-to-clipboard.png
> # Take screenshot in dom0 by selecting an area and adding border+shadow
> gnome-screenshot --area --include-border --border-effect=shadow 
> --file=/tmp/$MyScreenshot
> # Copy screenhot to AppVM command line argument / delete existing file
> qvm-run $MyAppVM 'rm -f /home/user/QubesIncoming/dom0/$MyScreenshot'
> qvm-copy-to-vm $MyAppVM /tmp/$MyScreenshot
> ###FIXME begin
> # I would like to just invoke the following
> # command via qvm-run in the AppVM
> # but the clipboard is just empty when using
> # this approach.
> # running the same command
> # xclip -selection clipboard -t image/png 
> /home/user/QubesIncoming/dom0/qvm-screenshot-to-clipboard.png
> # therof I have put the command into a helper
> # script in my AppVM:
> # qvm-run $MyAppVM /home/user/qvm-screenshot-to-clipboard-appvm.sh
> # the script is working when it is launched from
> # an already opened gnome-terminal window
> # but it will not work when the script is invoked
> # from dom0 via qvm-run or through an own 
> # strangely it is also not working when I start
> # the script from within the appvm
> # 'xterm -e

If interested, I've recently made a similar script that works a little 
differently. I'll put it here as having options and choice is a good thing.

mv "$(xfce4-screenshooter -fo ls)" ~/Screenshots
 ( sleep 3 )
qvm-move-to-vm Base ~/Screenshots/screenshot_*

I know many here don't need an explanation since it's a rather straight forward 
simple working script that "just works", but for those who may need it, here 
are some considerations to take into account about the script:

- The mv "$() part of the script serves as a function to remove "save as" and 
instead auto-save with the name screenshot_+date+timestamp. 

- Never remove the -o attribute if you want the mv "$() part of the script 

- The first line decides where to save the screenshot, and the third line pulls 
the screenshot from this location. By narrowing down an empty folder 
specifically this use-case, you avoid false positive transfers, although those 
are unlikely in dom0 anyway.

- By default this scripts sends screenshots to an offline AppVM that I 
frequently have running in the background for offline applications and daily 
used data.

- AppVM name used: Base

- Fullscreen, keep the f attribute.

- Region, change -fo to -ro

- Window, change -fo to -wo

- The screenshot_* part, will move any files or folders beginning with 
screenshot_*, at the given address location. If you got older screenshots 
there, then they will also be moved. This should not be a big problem though, 
if you only use these scripts and keep the folder empty.

- You can also optionally keybind scripts to different AppVM's, so you don't 
have to move them a second time from the standard AppVM.

- Need longer time, for example to carefully select text in region screenshots, 
then expand the sleep timer to, say, 20 seconds.

- Make scripts executable and put them in dom0 $HOME/ folder. Then simply just 
keybind them in Qubes Menu --> System-Tools --> Keyboard ---> Shortcut tab. 

- If dom0 is ever compromised, or the AppVM you backup your scripts to is 
compromised, be sure to check the scripts before putting them back in dom0 in 
the future. 

My own favourite version is region selection, set to 10 seconds, keybinded to 
the Screenshot key. 

mv "$(xfce4-screenshooter -ro ls)" ~/Screenshots
 ( sleep 10 )
qvm-move-to-vm Base ~/Screenshots/Screenshot_*

All the others are scripted too, but I need to hold down Ctrl key, shift key, 
etc. to make those work. I also keybind for different AppVM's, where I include 
a letter, where the letter denotes the AppVM. For example shift+w+printscreen, 
will send a screenshot to my work AppVM, while shift+s+printscreen sends the 
screenshot to my Study AppVM. 

You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to