I am looking for a way to execute a command with a keyboard shortcut. For example, the command "screenshot" should start the screenshot program within the respective VM or the command "nautilus" should pop up a file browser window of the VM that is currently being worked with.
If I set up a keyboard combination for this in dom0 in the xfce keyboard settings, then I would have to set a different keyboard combination for each Qube:
Ctrl+Alt+1 for Qube1: qvm-run Qube1 nautilus
Ctrl+Alt+2 for Qube2 qvm-run Qube2 nautilus
So, how can I do the same thing at the qube level instead of in dom0?
You can install the autokey program, but it requires me to write a python script, and I don't know how to express a simple shell command in python.
Here's a script that does exactly this.
Edit it to do something with $QUBE.
Associate it with a shortcut.
#!/bin/bash
ID=`xdotool getwindowfocus`
QUBE=`xprop _QUBES_VMNAME -id $ID|cut -f2 -d\" `
if [[ "$QUBE" == "_QUBES_VMNAME: not found." ]]; then
exit
else
# Do something with $QUBE
fi
The if clause is to exclude dom0 windows, but you could adapt that if
you *do* want action in dom0.
I made a bash script called qvm-run-in-focused-vm that accepts one command as parameter and then uses the structure @unman showed to run that command either in dom0 or the VM that has the focus.