[qubes-users] Re: How to assign keyboard shortcuts to a VM?

Dear unman,

thank you very much for your help (and thank you Sven for being so cooperative). It works fantastic. So, for example, if we wanted to give a user instructions on how to start the screenshot tool via keyboard shortcut in any active Qube (assuming the tool is installed there), it would be like this:

1) Open xterm in dom0
2) Type "cd /home/USERNAME/Documents" and hit enter if you want your script to be saved there.
3) Type "nano Screenshot.sh" and press enter.
4) Type the following script:

#!/bin/bash
ID=`xdotool getwindowfocus`
QUBE=`xprop _QUBES_VMNAME -id $ID|cut -f2 -d\" `
if [[ "$QUBE" == "_QUBES_VMNAME: not found." ]]; then
  exit
else
qvm-run $QUBE "gnome-screenshot -a"
fi

5) Press Ctrl+x, then y, then Enter.
6) Make the script executable by typing "chmod +x /home/USERNAME/Documents/Screenshot.sh" and pressing Enter.
7) Open System Tools > Keyboard > Application Shortcuts (this works in this way as long as you don't have the KDE desktop installed in dom0). Click "add". Type the path to your script: /home/USERNAME/Documents/Screenshot.sh
Click "OK" and press a keyboard shortcut.
8) Now you are able to invoke the screenshot tool with your keyboard shortcut in the Qube you are working with and drag a frame with the mouse over what you want to take a picture of.* The pictures will be automatically saved in the folder "Pictures" in the home directory of the Qube.

*If you want the whole screen to be photographed automatically instead, change the line "qvm-run $QUBE "gnome-screenshot -a" to "qvm-run $QUBE "gnome-screenshot" You can find out more possibilities in the terminal of the Qube with the command "gnome-screenshot --help".

If it does not work, the program "gnome-screenshot" is not installed. Open a terminal of the template and install the program with "sudo dnf install gnome-screenshot" if it is a normal fedora template. If it is a Debian template, type "sudo apt-get install gnome-screenshot". After installation, shut down the template and restart the Qubes based on the template.

All the best
Michael Singer