Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #18 add an option for allowing to open an existing quick note when creating a new one #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

FaintWhisper
Copy link

The functionality for adding quick notes is now customizable through a new toggle integrated into the plugin's settings tab. Users can activate this new option to allow opening an existing quick note when creating a new one. On the contrary, disabling it reverts to the current behavior: if a daily note with the same name exists, new quick notes will adopt the same name, followed by a unique auto-incremented integer and, if no daily note with that name exists, a new quick note will be created with the data format chosen by the user.

By default, I have chosen to enable this feature, as I believe it is the preference of most users, but I recognize that it can be somewhat subjective.

This feature addresses issue #18.

@FaintWhisper
Copy link
Author

I just realized that this feature will also address issue #31, which is a duplicate of #18.

@gerardbosch
Copy link

gerardbosch commented Nov 11, 2023

Hi @RYSKZ merging this PR would be nice! I found Tray plugin very useful to autostart Obsidian minimized (using Linux), but considering that this PR is merged, I realized that there's no convenient enough way to insert a quick note without changing context. So I researched a little and come up with this solution to add a quick-notes to the daily note file.

I wrote a small script that relies on https://github.com/coddingtonbear/obsidian-local-rest-api plugin, to insert quick notes from a terminal.

I have aliased the script obsidian-quick-note below, to q, and by using a drop-down terminal like dderm or Guake, I got a very efficient way to capture quick notes: I just hit the terminal hotkey, type q this is a quick note blahblah..... and that's it! I don't even need to switch any window or touch the mouse to capture a note.

The script here: https://github.com/gerardbosch/dotfiles/blob/main/home/bin/obsidian-quick-note

image

Result:

image

This is the template I'm using to create my daily notes, which contains a "Quick notes" section/heading:

---
tags:
  - daily-note
---
# Quick notes

# What's up for today...

# Actionable tasks

I hope this helps someone!

@FaintWhisper
Copy link
Author

Hi @gerardbosch,

I have been thinking seriously about this since I added this new feature. Currently, I am also facing the problem of the inability to quickly create a new note to jot down information relevant to the task I'm working on without having to switch context and interrupt my workflow. Currently, I have to bring Obsidian to the foreground using the dedicated hotkey I have set up in Tray and then, within Obsidain, I use another hotkey associated with a Quick Add script to create a new quick note. I find it a bit tedious to have to go through this two-step process to do this each time, and manually toggling the setting I added in the options menu is far from convenient, so I've come up with a new solution.

Here's what I'm proposing: within the Tray plugin, we should have two coexisting options. The first option would be to create a daily note, but it wouldn't allow duplicate entries, if the hotkey is pressed and the note exists it will open it up instead. The second option would be to create a quick note with a predefined template name, and it would allow for duplicates by inserting an auto-incremental numeric suffix. Each of these options would have its own dedicated hotkeys, and you could also specify a different destination folder for where these new notes will be saved. Both of these can be configured in the plugin settings panel.

In a nutshell, here's what I'm suggesting:

  1. <Hotkey 1 (e.g., Alt+q)>: Bring Obsidian to the front or back to the tray.
  2. <Hotkey 2 (e.g., Alt+w)>: Create a new quick note.
  3. <Hotkey 3 (e.g., Alt+e)>: Create today's daily note if it doesn't exist; if it does, open it.

With this new approach, I believe we can eliminate the need for the toggle I added in the settings, as I don't think anyone will require it, as what I am proposing now is much more flexible. Let me know what you think.

As for your solution, thanks for sharing it! It is very practical, and I will use it while I find time to work on this new proposal. I prefer to write directly in Obsidian, as it allows me to take advantage of other plugins and handy features that are built into Obsidian and I think that for long-form writing directly in Obsidian will be a better experience than using the terminal, so I will try to implement this new version of the feature, and I will update this PR when it is finished.

@gerardbosch
Copy link

Sounds good! allowing to run any Obsidian command from Tray plugin via global hotkeys could be cool! I think there's already an issue for this here #23

My quick script is more intended to quickly insert ideas, short notes or reminders in a couple of keystrokes :) and to organize or further elaborate it later inside the Obsidian interface. For example taking a quick note or reminder during a meeting without much worry 🙂

@FaintWhisper
Copy link
Author

FaintWhisper commented Feb 10, 2024

Sounds good! allowing to run any Obsidian command from Tray plugin via global hotkeys could be cool! I think there's already an issue for this here #23

Sorry for the delay in responding, these months have been incredibly hectic :(

You read my mind! I was going to suggest this too.

I did some research and, at first, couldn't find a way to get the commands available in the documentation. However, I found that the Advanced URI plugin can list all the available commands and looking at the source code it looks like there is an attribute that can be accessed to get this list (this.app.commands). Also, there is a command that can be used to trigger a command execution by providing the id. of the command to be executed (this.app.commands.executeCommandById()).

However, after thinking about how to implement it in Tray, I came to the conclusion that it is better to develop and use a separate plugin for this, as integrating it in Tray will make the user interface of the plugin more complex. I'm unsure whether Obsidian supports the level of dynamism required within the settings panel of the plugin or if this mapping should be handled through the command palette (which, in my opinion, would feel a bit weird to use). In the case of using text entries to specify the command names or ids. to map, instead of a list or menu with the options already filled in, will result in a strange UX.

Fortunately, there is already a plugin that allows you to assign any available command to arbitrary global hotkeys that are active system-wide (i.e., no matter if Obsidian is minimized, in the tray or in the foreground, they will still work):
https://github.com/mjessome/obsidian-global-hotkeys

I recommend to use my fork instead, because I made changes to make it compatible with Tray (disable the unregistering of global hotkeys assigned by other plugins, such as Tray):
https://github.com/FaintWhisper/obsidian-global-hotkeys

I could not find this plugin in the Obsidian third-party plugin repository, so, if you decide to use it (or my fork), you should carefully review the code, and then you need to install it manually or through Obsidian BRAT (using the add beta plugin for testing command and providing the URL of the repository). I tested it and it works perfectly. This plugin lists all available commands in its configuration page, and if you have a lot of plugins like me, you can see the problem I mentioned above regarding the integration of this in Tray.

I think using this plugin alongside Tray is the simplest solution to achieve this functionality, addressing also #23. Alternatively, another option is to use this other plugin that allows you to call any command by a URI (even ones that don't expose any, as the other plugin referenced earlier), which you can then use to integrate it into other applications or assign it to any hotkey using AutoHotKey or similar software:
https://github.com/deathau/command-uri-obsidian/blob/main/README.md

@FaintWhisper
Copy link
Author

I'll push the changes I've made to the pull request since my previous commit, including the latest modifications outlined in my previous comment, in case anyone find them as useful as they have been to me. Specifically, these changes allow for the configuration of separate directories and note filename formats for quick notes and daily notes, with the added capability to set independent hotkeys for each. In addition, I have retained the option to toggle the duplication of daily notes when the hotkey is activated several times in the same day, in case it is beneficial to somebody.

…tories and note filename formats for quick notes and daily notes, with independent hotkey settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants