Always open today's daily note in the same pinned pane

I always have my daily note pinned in the topleftmost pane.
But each morning my workflow is a bit cumbersome:

  1. Remember to unpin yesterday’s note
  2. Click the Open Today’s Note button
  3. Repin today’s note

Ideally I would just need to click the Open daily note button (or use the associated keyboard shortcut) and that would update the same pane with today’s new note, not open it in a new pane. Or even better, the daily notes plugin would prompt me to do this the first time I open Obsidian on a new day.

I’m not sure of the best way to implement this. Perhaps treating today’s daily note as a special type of pane.

29 Likes

bump.

One way to implement this could be to add the ability to pin folders, ie to restrict a pane to only opening links from a certain folder (presumably your daily notes folder). Whenever you try to open a link to a note from anywhere in the app, if there is a pane that is pinned to the folder that the note is in, then that pane would behave as if it is not pinned during this situation. In code, you could do that by altering the functionality of a pin or by automatically un-pinning and re-pinning affected panes (exactly as OP is doing).

This would be pretty useful functionality for MOCs too. In addition to folder-pinning, you could also do tag-pinning, where a pane can only open notes with a given #tag.

I also would like to be able to pin a daily note and have the pin advance each day to the next daily note. Perhaps an alias? The alias always points to the current daily. Allow us to pin the alias rather than the actual daily note. BTW, the thing I want to pin this way is the outline of the current daily note.

1 Like

+1 To the op idea

+1 was really hoping I’d search for this and already find a solution

Anu news regarding this feature request, I also would really like this kind of functionality.

I would love to see this feature, too. Preferentially, I’d be able to always have two panes fixed to show the current and next day.

I’m new to daily notes, and quickly found I’d like this feature as well.

An interesting way to tackle this could be to add the ability to pin a note into the templating system. So I could add “PINME” to my template, and voila.

+1 would be great

+1 - I came looking to see if there was a way to do this already that I’d missed. I’d settle for a way to just auto-pin today’s daily note but the OP’s request is much nicer, more powerful, alternative.

I don’t know if I understood correct, but if you have Templater plugin installed you can create a js script and add

app.commands.executeCommandById("workspace:toggle-pin")

or if you wanna test this before create the script and assing your template, paste code below into your note and change for preview mode

<%+ app.commands.executeCommandById("workspace:toggle-pin") %>

So, I think you can achieve this together Dayli Notes and Templater plugins together.

I hope this can help

1 Like

That’s awesome, thank you @m4sk4r4 ! - It took a little figuring out (because of my lack of knowledge here) but I have it now.

For anyone looking to do the same, I set a scripts folder in Templater’s config page in which I have a pin_me.js user script which contains:

function my_function () {
    app.commands.executeCommandById("workspace:toggle-pin");
    console.log("Note file pinned.");
    return "";
}
module.exports = my_function;

(The console.log() message is not necessary, but I had the console open to see if I was breaking anything, so added it as a check…)

Then in my Daily Note template I have a line with <% tp.user.pin_me() %>.

This seemed to work fine except, initially, the tp code above was replaced with the text ‘undefined’, I guessed because the function didn’t originally return anything. I “fixed” that by returning an empty string but I’m not sure if that’s the right JS way to do it, or indeed if I need all those semi-colons :grin: Either way, my Daily note now pins itself on creation.

Thanks again @m4sk4r4, you’re a star!

5 Likes

I am using this on my PKM for example for my courses section.

When I click a course note, it executes a command sequence.

e.g: When I open a course note:

  • Close left sidebar;
  • close right sidebar;
  • pin course note;
  • close others notes;
  • open a course into a frame through plugin “Custom Frames”

It is necessary Force note view note, templater, Custom Frames because I wanna when I click on the note, force to open it on preview mode and execute templater script at “run:”

See gif:
2022-08-17 00-58-34

Frontmatter

uid: 202207190935
title: Duolingo - English
aliases: []
tags: [Courses]
categories: English
start_date:
end_date:
url: Duolingo
icon: app://local/home/gabriel/Documents/PKM/Attachments/Icons/duolingo.png
author:
author_url:
platform: Duolingo
platform_url: Duolingo
rating:
status: in-progress
obsidianUIMode: preview
cssclass: cards cards-1-1
date created: 2022-07-19T09:35:34-03:00
date modified: 2022-08-17T00:18:23-03:00
run: <%+ await tp.user.course_preview() %>

course_preview Templater script

async function course_preview(tp) {
    const activeFile = app.workspace.getActiveFile();
    const customFrame = activeFile.basename.toLowerCase().replaceAll(" ", "-")
    
    if (! app.workspace.activeLeaf.pinned) {
        app.commands.executeCommandById("customizable-sidebar:close-left-sidebar")
        app.commands.executeCommandById("customizable-sidebar:close-right-sidebar")
        app.commands.executeCommandById("workspace:toggle-pin")
        app.commands.executeCommandById("workspace:close-others"); 
        app.commands.executeCommandById(`obsidian-custom-frames:open-custom-frames-${customFrame}`)
    }
}
module.exports = course_preview
1 Like

I like that, it’s very clever! :clap:

I like the templater workaround ideas. I might even install templater for this. I also think it would be nice if the above could just be the default behavior for the daily note when pinned.

1 Like

pumpin up this idea, i do’t know how they didn’t do it already