Plugin for Tracking Active Time Spent on Notes and PDFs (with Search Functionality)

Hi everyone,

I’m looking for a way to track how much active time I spend on individual notes and PDFs in Obsidian. By active time, I mean the following:

  • Obsidian is the foreground application.
  • The cursor is focused within a specific note or PDF.
  • The timer should stop when I switch to another application, change notes, or when the cursor is no longer in the active note/PDF.

In addition, I want the ability to search for the time spent on a particular note or PDF, even if it doesn’t appear in the top 50 most recent notes or PDFs.

Desired Features:

  1. Active Time Logging for Notes:
  • The plugin should track the amount of time I spend actively working on each note.
  • Time should only count when Obsidian is the foreground app, and the cursor is within the active note.
  • If I switch to another note or another application, the timer for that note should pause, and resume when I return.
  • I would like the time log to store the last 50 notes I’ve worked on, along with the total time spent on each note and the timestamp of the last time I accessed it.Example Table Format:

yaml

Copy code

### Active Time on Notes
| Note Title          | Active Time (Minutes) | Last Accessed          |
|---------------------|-----------------------|------------------------|
| Note 1              | 12                    | 2024-09-30 10:45:00    |
| Note 2              | 8                     | 2024-09-30 11:00:00    |
| Note 3              | 24                    | 2024-09-29 14:30:00    |
  1. Active Time Logging for PDFs:
  • I also work with PDFs opened directly within Obsidian, and I’d like to track the time I spend on these as well.
  • Similar to notes, the plugin should log time spent while I am actively viewing a PDF (while Obsidian is in focus).
  • PDF time logs should appear in a separate table from notes within the same log file or note.Example Table Format for PDFs:

yaml

Copy code

### Active Time on PDFs
| PDF Title           | Active Time (Minutes) | Last Accessed          |
|---------------------|-----------------------|------------------------|
| PDF 1               | 15                    | 2024-09-30 12:45:00    |
| PDF 2               | 5                     | 2024-09-30 13:30:00    |
  1. Search Functionality:
  • In addition to tracking the most recent 50 notes or PDFs, I need the ability to search for any note or PDF and view the total time I’ve spent on it. This is important in case I’ve spent time on a note or PDF that is no longer in the top 50 but I still want to check how much time I invested in it.
  • Ideally, this search could be integrated into Obsidian’s search functionality or provided as a separate command (e.g., /time-tracker search <note name> or a quick command palette option).Example Search Workflow:
  • I could enter a command like /time-tracker search "Note Title", and the plugin would return:

sql

Copy code

Time spent on "Note Title": 35 minutes
Last Accessed: 2024-09-20 15:30:00
  1. Log Display:
  • I would like to display the last 50 notes I’ve worked on in the log, along with their active time. Similarly, the plugin should maintain a log of the last 50 PDFs I’ve interacted with.
  • Both tables (for notes and PDFs) should update in real time or at regular intervals and display in a single note or file within Obsidian.
  1. Foreground and Focus Detection:
  • The plugin should be able to detect when Obsidian is the foreground application and when the cursor is actively focused on a note or PDF.
  • Active time should stop when I move away from Obsidian or change focus to a different note or file.

Use Case:

This feature would help me analyze how much time I am spending on my notes and PDFs within Obsidian. I use Obsidian as my primary tool for note-taking and research, and I often open PDFs alongside notes. Tracking active time spent on each file would be incredibly helpful for productivity analysis and time management.

Additionally, the ability to search for time spent on any note or PDF, even if it’s no longer in the top 50, would ensure that I can always access this information when needed.

Moved to Plugin ideas.