Giorgos Sarigiannidis1k downloadsTrigger actions based on document visibility changes.
Sentinel is a plugin for Obsidian that allows you to update properties or run commands based on document visibility changes. For example, you can add a views property that auto-increments every time a Note opens, a modified property that captures the current datetime when you exit a Note with modifications, run a Linter when a Note opens or exits, and so on.
https://github.com/user-attachments/assets/eb7f4ae7-2448-4ca1-913a-9b63d799f8bf
Go to the plugin's settings to add your actions. Each action includes the following fields:
#tag - Prefixing the value with a # (e.g. #tag) will match notes that have the specified tag. For example, #tag-1 would trigger the action on any note that includes the tag "tag-1".Folder/ - Putting / at the end of your value (e.g. folder/), will target notes within the specified folder. You can target nested folders like folder/subfolder/. For example, My Folder/ would target all notes under the "My Folder" folder, and My Folder/Subfolder all the notes under the specific subfolder. Note name - Putting plain text (e.g. Note Name) will target a note with the exact title (case-insensitive)!. For example, !#tag-1 will trigger on any note EXCEPT for those containing the tag "tag-1". !My Folder/ will trigger on any note EXCEPT for those under the "My Folder" folder. !My Note will trigger on any notes EXCEPT for the note with the title "My Note". #tag-1,folder/,Note Name will trigger if the note matches ANY of these conditions (has "tag-1" OR is in "folder" OR has the specified name). On the other hand, !#tag-1,!folder/,!Note Name would trigger only if ALL conditions are true (note doesn't have "tag-1" AND isn't in "folder" AND isn't named "Note Name")./^Recipe-*.*/ would target all notes with a title beginning with "Recipe-").{{increment}}, {{date}}, {{time}} or {{title}}. You can also set a "Skip existing", which will skip setting the property if it already exists.
The property option accepts the following dynamic variables:
Both {{date}} and {{time}} allow you to change the default format using a format string. To set a format string, add a colon (:) followed by a string of Moment.js format tokens, for example {{date:YYYY-MM-DD}}.
You can use {{date}} and {{time}} interchangeably with format strings, for example {{time:YYYY-MM-DD}}.
Essentially, it follows the same patterns described in the Template variables section of the Obsidian Help pages.
Using {{increment}} you can increment a specific value. This can be handy if you want to add a property for tracking the views of a Note. The variable allows you to set the starting value and the increment step, with the following pattern: {{increment:<initial_value>,<increment_step>}}. For example, {{increment:100,10}}, would use "100" as its initial value, and increment by "10" (so, on your next visit, the value should be "110", then "120" and so on).
If no other parameters are used, it will use by default "0" as the initial value and "1" as the increment step.
You can use {{title}} to retrieve the title of the active note. Nothing fancy here, and I'm not sure when would one need it. I just kept it because it was among the officially supported Template variables.
Currently, there are 3 ways to install the plugin:
gsarig/obsidian-sentinel.main.js, styles.css, manifest.json files from the latest release./.obsidian/plugins/ named sentinel . If plugins folder doesn't exist, then create it manually. /sentinel folder. You can use BRAT to test beta versions of the plugin:
1.0.2-beta.1.
If you encounter any issues or have questions, feel free to reach out via the plugin's GitHub repository.