OK, I spent WAAYYY more time than I should have figuring this out, but it was an interesting puzzle! It cannot be completely done within a shortcut as I first thought, but this is pretty easy.
It looks a little long, but all we are doing is creating a very simple shortcut to put your alert message up. Then we are using the Mac scheduler, launchd, to run it when you say to in the script - like every 45 minutes 10-6. It will run every day as set up, and I added steps in to verify stuff as you go:
First, create the Notification in Shortcuts.
Step 1: Create a New Shortcut
• In Shortcuts, click the ”+” button at the top.
• Name your shortcut.
Step 2: Add a 'Show Notification'
• In the right sidebar, search on Show Notification. Double click it.
• If you want a Title, click 'Show More'
• Add a text message where 'Hello World' is.
Now we use MacOS scheduling to run this baby every 45 minutes, 10 AM - 6 PM (last one at 5:30 I think):
Step 3: Verify the shortcut is saved and working:
• Open Terminal
• type: Shortcuts list (you should see the name of your shortcut there)
• Test running it: shortcuts run '<name of your shortcut>' (Did it pop up your alert?)
Step 4: Create a scheduling script
• Open Terminal.
• type: nano ~/run-reminder.sh
• paste this in:
#!/bin/zsh
/usr/bin/shortcuts run "shortcut name" (the name you saw in step 3)
• Press Ctrl+O, Enter, then Ctrl+X to save and close. (this adds the .sh file to your users/<my name> folder
• Make it executable - continue typing in Terminal: chmod +x ~/run-reminder.sh
Step 5: Schedule it to run (using launchd)
• Create a plist file. In Terminal type: nano ~/Library/LaunchAgents/com.user.reminder45.plist
• Paste the following script. Before you copy it to paste, change 'yourusername' to your real user name on the Mac. If you are unsure of it, type: WhoAmI in Terminal.
• You can see the times the shortcut will run the hours/minutes starting at 10/0 if you want to change or add times. These are done every day:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.reminder45</string>
<key>ProgramArguments</key>
<array>
<string>/Users/yourusername/run-reminder.sh</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict><key>Hour</key><integer>10</integer><key>Minute</key><integer>0</integer></dict>
<dict><key>Hour</key><integer>10</integer><key>Minute</key><integer>45</integer></dict>
<dict><key>Hour</key><integer>11</integer><key>Minute</key><integer>30</integer></dict>
<dict><key>Hour</key><integer>12</integer><key>Minute</key><integer>15</integer></dict>
<dict><key>Hour</key><integer>13</integer><key>Minute</key><integer>0</integer></dict>
<dict><key>Hour</key><integer>13</integer><key>Minute</key><integer>45</integer></dict>
<dict><key>Hour</key><integer>14</integer><key>Minute</key><integer>30</integer></dict>
<dict><key>Hour</key><integer>15</integer><key>Minute</key><integer>15</integer></dict>
<dict><key>Hour</key><integer>16</integer><key>Minute</key><integer>0</integer></dict>
<dict><key>Hour</key><integer>16</integer><key>Minute</key><integer>45</integer></dict>
<dict><key>Hour</key><integer>17</integer><key>Minute</key><integer>30</integer></dict>
</array>
<key>StandardOutPath</key>
<string>/tmp/reminder45.log</string>
<key>StandardErrorPath</key>
<string>/tmp/reminder45-error.log</string>
</dict>
</plist>
• Save the file: Press Ctrl+O, Enter, then Ctrl+X. You are back in Terminal.
Step 6: Activate schedule
• In Terminal: launchctl load ~/Library/LaunchAgents/com.user.reminder45.plist
• You should see a little alert saying it has been added to 'run in background'. To be sure, check Settings/Login Items & Extensions, Allow in the Background. You'll see run-reminder.sh there!
Step 7: Test the scheduled task
• You tested the script earlier, now test the scheduled task. Some steps to check while waiting for it to run:
Verify it's running: ls -l ~/run-reminder.sh
You should see something like:
-rwxr-xr-x 1 johndoe staff 100 Apr 11 15:00 /Users/johndoe/run-reminder.sh
• Check if the launchagent is loaded: launchctl list | grep reminder45
If no line is returned, check the log files (below)
• Test the script manually. You should see the alert pop up! -->
~/run-reminder.sh
• If the alert doesn't come up, check the log files. If empty, they did not run:
cat /tmp/reminder45.log
cat /tmp/reminder45-error.log
There are other things to check, hopefully if you were careful it will run! It runs great on mine, I have the alerts set to 5 minutes lol.
One last note - if you want to change the script with the hours/minutes in it, or probably the shortcut too (I did not test that), just unload and reload the scheduling script:
launchctl unload ~/Library/LaunchAgents/com.user.reminder45.plist
launchctl load ~/Library/LaunchAgents/com.user.reminder45.plist
You can also see that using this script, you can have the alerts come up any time - plus, they don't have to be exactly every 45 minutes. Just modify/add a modified hours/minutes line in the script like this:
<dict><key>Hour</key><integer>10</integer><key>Minute</key><integer>0</integer></dict>
Note macOS scheduling using launchd (what we are using here) does not wake the Mac from sleep for non-critical tasks such as notifications or shortcut alerts. So the alert will not appear if the Mac is asleep in any form - for example, asleep on laptop with lid open or closed. It will appear if the Mac is awake and the screen saver is on or the screen is dimmed though!
Good luck - it's an easy process to follow - let us know how it goes!