There’re quite a few routes to doing this, but as far as I can see, Rules is the only way to trigger anything based on the start on a calendar event. So, I’d start there. From Rules, it’s pretty easy: you trigger Shortcuts, so it can do anything Shortcuts can.
My Rules trigger/actions setup is pretty simple:
Timeblock Warning simply shows a notification with the text “Timeblock starting in ten minutes.” (I can probably delete this now that I have Dota’s fullscreen notification set up; more discussion here.)
Timeblock Start, which you can install here, looks like this:
The AppleScript simply minimizes all windows.
The next few steps calculate the duration of the timeblock.
If it’s a distraction-free timeblock, I include the □ character in the event title. The If statement filters for those and triggers Focus’s hardcore focus mode for the duration of the timeblock. This disables apps like Discord, this forum , news sites, and so on.
Otherwise the Shortcut switches focus modes, prompts me with a little modal asking what I’m gonna do, then launches a URL scheme that sets up my space. (Since I create these timeblocks from Obsidian, the links are always to the relevant note in Obsidian.) It would be pretty easy to include a URL that triggers Bunch or a Keyboard Maestro macro or another Shortcut in order to modify the workspace with those apps instead.
Hope this helps! I’ll probably copy+paste this into my blog at some point.