Probably not the solution you’re looking for, but I’ve adapted Sven’s cached DVM script to my liking and am using it, among other things, to shut down VMs. If you bind the shut down command /home/username/run-in-focused-vm 'sleep 3 && sh -c "(exec sudo poweroff) || (exec poweroff)"'
to, e.g. Ctrl + Alt + Q
and make sure that your apps understand Ctrl + Q
as a shutdown command (many apps do by default), then you can just shutdown VMs with open apps by making sure that the app window is in focus and then press Ctrl + Alt + Q
, followed directly by Ctrl + Q
, which shuts down the app gracefully and a few seconds later the VM. If multiple windows of that VM are open, make sure you Ctrl + Q
on them all inside the 3 seconds.
That’s how I do it, at least.