Here's what I came up with. Was simpler than I thought.
Create shell script daily_goals.sh:
#!/bin/bash # this is needed to launch Chrome as a new window. Since it's a new window, it will open in the foreground in current space/desktop. open -n -a Google\ Chrome # this sleeps for 1 second. It's necessary because otherwise the website, called below, will open in existing Chrome window, which may be located in another desktop. I think sleeping lets the next `open` call find the newly opened Chrome window, and replace the new tab with the provided website. sleep 1 # the website I provided. open http://joesgoals.com
Create /Library/LaunchDaemons/daily_goals.plist
:
<?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>daily_goals</string> <key>ProgramArguments</key> <array> <string>/Users/user/Work/daily_goals.sh</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>07</integer> <key>Minute</key> <integer>00</integer> </dict> </dict> </plist>
Add to launchctl:
launchctl load -w /Library/LaunchDaemons/daily_goals.plist
In summary, this launches joesgoals.com every morning at 7am in a newly opened Chrome instance. If the laptop is asleep at 7am, it should open JoesGoals when the laptop is resumed from sleep. I'll update later if I see any quirks resuming osx in different desktops/spaces (with or without Chrome). Hoping it won't be an issue.