Thanks for the idea, never occured to me to do it this way.
I've made a little improvement from that one liner

(Although this is for headless mode.)
You just paste the lower code in "Applications -> Apple Script -> Script Editor" and save as Application as described above.
Now you can drag the script to the dock and run an OS in headless mode. After it runs, it gives you a dialog to either 'Hibernate (through VBox feature)', 'Shutdown (as in virtually pressing the power button [you need acpid daemon running for Linux for this to work]) and 'Destroy (which will kill the OS instance immediately)'.
You need to change the first line of the script to write in your VM instance name. (Written as 'Ubuntu Linux' for now.)
If you want to use this for multiple OS, you just need to change the VM instance name and save it as a different application and you might want to actually put the folder in the dock instead.
If you want to enable RDP remote management, then you need to edit the 'VB_RDP' value to a port number instead of "off".
And if you want to look niftier than the default icon, you can google image for '[your OS name] icon' (be sure to pick the one with proper transparency) and grab one and use something like
img2icns to turn the file into an icon file then
use that as the custom icon.
Looking pretty.
Code: Select all
set VB_GUEST to "Ubuntu Linux"
set VB_RDP to "off"
set VB_PATH to "/usr/bin/"
set VB_VM to quoted form of VB_GUEST
do shell script VB_PATH & "VBoxHeadless -s " & VB_VM & " -v " & VB_RDP & " >/dev/null 2>&1 &"
display dialog "VirtualBox " & VB_VM buttons {"Hibernate", "Shutdown", "Destroy"} default button 1
set VB_ACT to button returned of result
set VB_CONTROL to VB_PATH & "VBoxManage controlvm " & VB_VM
if VB_ACT is "Hibernate" then
do shell script VB_CONTROL & " savestate"
else if VB_ACT is "Shutdown" then
do shell script VB_CONTROL & " acpipowerbutton"
else if VB_ACT is "Destroy" then
do shell script VB_CONTROL & " poweroff"
end if
