sqeptyk

ReadMe

Jun 9th, 2026
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | Help | 0 0
  1. TASK COMPLETION TRIGGER FOR OBSIDIAN
  2. by sqeptyk
  3. Automatically fire a Templater template when you check off a task
  4. in the Tasks plugin — including in Reading mode.
  5. No custom plugins required. Works with Templater's startup system
  6. and Obsidian's native vault event API.
  7.  
  8. HOW IT WORKS
  9. A startup template registers a listener on vault file changes.
  10. When a file in your watched folder is modified, it diffs the old
  11. and new content to detect a newly completed task. If that task
  12. contains a mapped tag, the corresponding Templater template fires
  13. automatically.
  14.  
  15. REQUIREMENTS
  16. Obsidian
  17. Templater plugin (latest)
  18. Tasks plugin (optional but intended)
  19.  
  20. FILES
  21. task-trigger-listener.md
  22. The core listener. Add to Templater Startup Templates.
  23. Edit WATCH_FOLDER and TASK_TAG_MAP to match your setup.
  24. add-task-trigger.md
  25. Companion template. Run it to add new tag -> template
  26. mappings without editing the listener manually.
  27.  
  28. SETUP
  29. Place task-trigger-listener.md anywhere in your vault.
  30. Open Templater settings.
  31. Go to "Startup Templates" and add task-trigger-listener.md.
  32. Open task-trigger-listener.md and edit the configuration:
  33. WATCH_FOLDER
  34. The folder containing your task notes. Only files inside
  35. this folder will be watched. Example: "TASKS" or "LOGS"
  36. TASK_TAG_MAP
  37. Maps tags to templates. Add one entry per tag:
  38. "#yourtag": { template: "Templates/YourTemplate" },
  39.  
  40. The template path is relative to your vault root, no .md.
  41. Place add-task-trigger.md in your templates folder.
  42. Update LISTENER_PATH inside it to point to wherever you
  43. put task-trigger-listener.md.
  44. Restart Obsidian.
  45.  
  46. USAGE
  47. Add a tag to any task in a note inside your watched folder:
  48. - [ ] Do something #yourtag
  49.  
  50. Check it off. Your template fires automatically.
  51. To add new mappings, run add-task-trigger.md from the
  52. Templater command palette. It will prompt you for the tag
  53. and template path, then inject the entry into the listener.
  54.  
  55. IMPORTANT NOTES
  56. Tasks must live inside the WATCH_FOLDER to trigger.
  57. Tasks on your dashboard or in other folders will be ignored.
  58. The listener diffs file content on every save, so it only
  59. fires when a task goes from unchecked to checked, not on
  60. every file edit.
  61. Only one template fires at a time. If you complete multiple
  62. tagged tasks in rapid succession, the processingTask flag
  63. prevents double-firing. Complete them one at a time.
  64. Works in Reading mode, Live Preview, and Source mode.
  65.  
  66. ADDING YOUR OWN TEMPLATES
  67. Your Templater template fires just like any other — it has full
  68. access to tp.system.prompt, tp.system.suggester, and all other
  69. Templater functions. Build your prompts and output logic the
  70. same way you normally would.
  71. The template is responsible for creating its own output file.
  72. The listener just fires it; what it does is up to you.
  73.  
  74. TROUBLESHOOTING
  75. Listener not loading?
  76. Check Templater settings -> Startup Templates.
  77. Restart Obsidian after adding it.
  78. Check the developer console (Ctrl+Shift+I) for errors.
  79. Template not firing after task completion?
  80. Make sure the task note is inside WATCH_FOLDER.
  81. Make sure the tag in the task exactly matches the tag
  82. in TASK_TAG_MAP, including the # symbol.
  83. Check that the template path in TASK_TAG_MAP is correct
  84. and the file exists in your vault.
  85. Template fires but errors out?
  86. Open the developer console and check for "Task Trigger"
  87. error messages.
  88.  
  89. LICENSE
  90. Do whatever you want with this. Credit appreciated but not
  91. required. If you improve it, share it back.
Tags: Obsidian
Advertisement
Add Comment
Please, Sign In to add comment