I don't use Time Capsule, but want to always trigger my nightly backup procedure, even if I use Apple menu for shut down.
Yes, KM has "shut down" and "restart" actions.
But, if I understand correctly, @Joe_Williams, is asking for something that intercepts the Apple menu.
This I want to see.
I don't have Time Capsule, but I do have a Synology NAS unit, with the primary share named "ApoNAS-Main".
This script works for me to disconnect the NAS:
tell application "Finder"
set diskList to every disk --whose ejectable is true
log diskList
eject "ApoNAS-Main" -- name of network share in diskList
end tell
You should find the name of your Time Capsule share in the Script Editor log.
While there is a KM trigger for "At System Sleep", I don't see anything for shutdown.
But there are KM Actions for both:
IAC, I use a custom Macro to put my Mac to sleep. Before I execute the "Put Computer to Sleep" action, I close all apps and disconnect all drives. Would that work for you?
Here is my "Close Apps & Sleep" macro.
Much of it is highly specific to my needs/workflow, but it should give you an idea of how to write one of your own.
I trigger it by name, but of course you can set any trigger you like.
Script to UnMount External Disks
tell application "Finder"
set diskList to every disk whose ejectable is true
if (diskList ≠ {}) then
repeat with oDisk in diskList
set diskName to name of oDisk
display notification "Now Ejecting Disk: " & diskName
eject diskName
end repeat
else
display notification "NO Disks Found to Eject"
end if
end tell