Replies: 10 comments 26 replies
-
1- When a user switches the active panel —> Save the caret position: line number and the count the amount of character:
2- When the file is closed —> Save the caret position: line number and the count the amount of character:
|
Beta Was this translation helpful? Give feedback.
-
I updated the first post in this discussion to include stuff related to new workspace events in Obsidian |
Beta Was this translation helpful? Give feedback.
-
I might rename this Events feature to Launchers or something. It might be a bit more specific. When these events/launchers will be implemented, I'll probably add Command palette as a launcher too, for the simple reason that then it can be turned off: a user could have shell commands that are not designed to be launched via the command palette. E.g. a shell command to show current file's size in statusbar could be launched when another file becomes active, but it does not need to unnecessarily fill command palette, which already has a huge list of commands. I'll also add Every n seconds to the list of actions. |
Beta Was this translation helpful? Give feedback.
-
New idea added:
|
Beta Was this translation helpful? Give feedback.
-
I added:
|
Beta Was this translation helpful? Give feedback.
-
Some progress...Just to confirm shortly that I've been able to get a shell command executed when Obsidian opens and quits, and when active pane changes (= either another pane is clicked, or another file is opened). |
Beta Was this translation helpful? Give feedback.
-
A link click event?@DaveyUS asked the following in #123 (comment):
Thank you for your question and feedback! 🙂 At least After switching the active pane event can be used for something close to what you are looking for (after the release of SC
I do not know Obsidian API completely, so I cannot say for all ideas if they are possible or not, but I like to have these conversations about things that could be nice to have, so that I can keep them on my mind and some day be able to tell if they can be implemented, even if I'm uncertain at the beginning. Hooking into link behavior is something that I'm not familiar with so far, but could be interesting. |
Beta Was this translation helpful? Give feedback.
-
(Just for the record: beta version A bug in After switching the active pane event: It's sometimes executed twiceSometimes, when switching the active pane, the event is triggered twice, and so all shell commands tied to the event, will also be executed twice. My current understanding is that this happens in Obsidian's side (Obsidian version 0.13.23), so it might be that there's not much I can do about it, but we'll see. If this bug is problematic for your shell commands, you can read more details and watch a demonstration video from a bug report that I made on Obsidian's forum: https://forum.obsidian.md/t/api-active-leaf-change-event-is-sometimes-triggered-twice/31841 I will update this discussion when I get more information. |
Beta Was this translation helpful? Give feedback.
-
Part 2 implementationThe following events are now under development:
Development process: #218 |
Beta Was this translation helpful? Give feedback.
-
Window open/close related eventsI added this to the list:
This is related to a new feature in Obsidian 0.15.x that allows locating panes in multiple windows. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This idea is about defining configurable events that can trigger shell commands to be executed. This would be one more step towards automation.
Event ideas so far
General
Editor
editor-paste
workspace event. Could have an option to cancel the default pasting behavior and use the output channel Current file: caret position to replace the pastable text with something else. This could e.g. allow doing custom formatting for pasted HTML or whatever.editor-change
workspace event.File handling
Special files / attachments
{{clipboard}}
variable. Try to search for an image on the web, then right click an image, select Copy image or something (do not save the image as a file), then go to Obsidian, open some note in editor mode and simply paste, and you'll see a pasted image file appearing in your vault, with a link to it being inserted in the note).editor-drop
workspace event.User interface
When the active note is closed.(Thanks Felipe for this idea!). Edit 2022-01-01: This will not be implemented, as After switching the active pane will usually cover this situation, too. See this comment: Events: Execute shell commands automatically when something happens #60 (reply in thread)window-open
andwindow-close
, Obsidian 0.15.3).Search
Note: I do not know yet, which one of these can be implemented in practice. Each event would need a similar event offered by Obsidian API, and I'm not familiar with what kind of events it provides. But ideas are always for good.
Event related variables
Some events might need variables to provide data related to the event. As event related variables would not be available outside of events,
I'd like to introduce just one variable,{{event}}
, so that a user clearly knows that this variable can only be used when a command is executed via an event. The{{event}}
variable would have a parameter that would indicate the actual data that is needed:{{event:file_name}}
/{{event:file_path}}
: The created/modified/deleted/moved file.{{event:search_keyword}}
Something else?Edit 2021-12-12: I think I'll create multiple variables for events, but they all will start with
{{event_
, e.g.{{event_file_name}}
. Then it's easier to handle different sets of arguments, different help texts and different autocomplete items.Beta Was this translation helpful? Give feedback.
All reactions