I am very happy to report success.
Originally Posted by ian-weisser
First, I created the script /home/<user>/Script/vmhalt:
Next, I edited /etc/init/lightdm.conf. Directly underneath the line "emits desktop-shutdown" I added:
# set primary variables
if pgrep -x vmware-vmx > /dev/null 2>&1; then
# send vm shutdown signal with user credentials
net rpc shutdown -I "<vm>" -U "$unpass" #unpass defined in credentials file
# wait 5m for vm shutdown.
while pgrep -x vmware-vmx > /dev/null 2>&1; do
if [ $counter -ge 60 ]; then
counter=$[counter + 1]
The result is that any shutdown (graphical, shell or remote) will hold the desktop open, wait for the virtual machine to shutdown gracefully, and then continue with a normal shutdown.
exec sudo -u <user> /home/<user>/Script/vmhalt