How can I check if Obsidian is already running?
In some cases, the question might come up when a Shortcuts workflow "cold-starts" Obsidian. Depending on the size of your vault and the list of enabled plugins, Obsidian might need a second or more to get into a fully responsive state. Which might cause a problem when Actions for Obsidian runs a Shortcuts action, expecting Obsidian to be fully up, and that isn't the case — because the actions call might be handled before the vault is completely initialized, plugins and all.
This is more of an iOS problem than a macOS one due to processing power and Obsidian's base code on each platform.
On macOS, you can check if Obsidian is in the list returned by the "Get Running Apps" action (c/o Actions app by Sindre Sorhus) but usually that is unnecessary.
On iOS, it's impossible to check whether Obsidian is running, since iOS doesn't allow Shortcuts to query which apps are running. (If that statement is somehow incorrect, please let me know!)
A workaround here is to open Obsidian once at the beginning of the workflow and give it a moment before running any AfO actions. If the workflow you're building is supposed to run on both macOS and iOS, it's a good idea to check for the OS first:
- Add a built-in "If" action.
- Select "Device Details" as the input.
- Click "Device Details" it and pick its "OS" attribute from the list to make the check about the type of operating system.
- Select "is" as comparator and "iOS" as the condition.
- Add a built-in "Open app" action, select "Obsidian".
- Add a built-in "Wait" action, set the delay to whatever is necessary for your vault.
If the workflow is iOS only, ignore the "If" block and just add the latter two actions.
Thanks to Kenny M. for the suggestion! ✌🏼