Skip to content

Instantly share code, notes, and snippets.

@pew
Created April 23, 2024 09:07
Show Gist options
  • Select an option

  • Save pew/67d38a063edc7e8d6d9a942e4d61e1f9 to your computer and use it in GitHub Desktop.

Select an option

Save pew/67d38a063edc7e8d6d9a942e4d61e1f9 to your computer and use it in GitHub Desktop.
utm restart vm

this is an apple script to toggle a restart of a specific UTM virtual machine. Replace the name Linux Ubuntu with your VM's name

tell application "UTM"
set vm to virtual machine named "Linux Ubuntu"
set vmStatus to get status of vm
if vmStatus is started then
stop vm
repeat until (get status of vm) is stopped
delay 1 -- checks every second to see if the VM has stopped
end repeat
start vm
else if vmStatus is stopped then
start vm
end if
tell application "System Events" to set visible of process "UTM" to false
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment