MCPcopy Index your code
hub / github.com/eatgrass/obsidian-pomodoro-timer

github.com/eatgrass/obsidian-pomodoro-timer @1.2.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.2.3 ↗ · + Follow
102 symbols 230 edges 18 files 2 documented · 2% updated 2y ago1.2.3 · 2024-05-30★ 23437 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Pomodoro Timer for Obsidian

image

Introduction

This plugin integrates a customizable Pomodoro timer into your Obsidian workspace, helping you focus and manage your time effectively.

Features

  • Customizable Timer: Set your work and break intervals to suit your productivity style.
  • Audible Alerts: Stay on track with audio notifications signaling the end of each session.
  • Status Bar Display: Monitor your progress directly from Obsidian's status bar to keep focusing.
  • Daily Note Integration: Automatically log your sessions in your daily notes for better tracking.
  • Task Tracking: Automatically refresh the 'actual time' field for the task in focus.

Notification

Custom Notification Sound

  1. Put the audio file into your vault.
  2. Set its path ralative to the vault's root. For example: your audio file is in AudioFiles and named notification.mp3, your path would be AudioFiles/notification.mp3. Don't forget the file extension (like .mp3, .wav etc.).
  3. Click the play button next to the path to verify the audio

Task Tracking

To activate this feature, first enable it in the settings. Then add pomodoros inline-field after your task's text description as below. The pomodoro timer will then automatically update the actual count at the end of each work session.

Important: Ensure to add this inline-field before the Tasks plugin's fields. Placing it elsewhere may result in incorrect rendering within the Tasks Plugin.

-   [ ] Task with specified expected and actual pomodoros fields [🍅:: 3/10]
-   [ ] Task with only the actual pomodoros field [🍅:: 5]
-   [ ] With Task plugin enabled [🍅:: 5] ➕ 2023-12-29 📅 2024-01-10

Log

Log Format

The standard log formats are as follows For those requiring more detailed logging, consider setting up a custom log template as described below.

Simple

**WORK(25m)**: 20:16 - 20:17
**BREAK(25m)**: 20:16 - 20:17

Verbose

- 🍅 (pomodoro::WORK) (duration:: 25m) (begin:: 2023-12-20 15:57) - (end:: 2023-12-20 15:58)
- 🥤 (pomodoro::BREAK) (duration:: 25m) (begin:: 2023-12-20 16:06) - (end:: 2023-12-20 16:07)

Custom Log Template (Optional)

  1. Install the Templater plugin.
  2. Compose your log template script using the log object, which stores session information.
// TimerLog
{
    duration: number,  // duratin in minutes
    session: number,   // session length
    finished: boolean, // if the session is finished?
    mode: string,      // 'WORK' or 'BREAK'
    begin: Moment,     // start time
    end: Moment,       // end time
    task: TaskItem,    // focused task
}

// TaskItem
{
    path: string,         // task file path
    fileName: string,     // task file name
    text: string,         // the full text of the task
    name: string,         // editable task name (default: task description)
    status: string,       // task checkbox symbol
    blockLink: string,    // block link id of the task
    checked: boolean,     // if the task's checkbox checked
    done: string,         // done date
    due: string,          // due date
    created: string,      // created date
    cancelled: string,    // cancelled date
    scheduled: string,    // scheduled date
    start: string,        // start date
    description: string,  // task description
    priority: string,     // task priority
    recurrence: string,   // task recurrence rule
    tags: string[],       // task tags
    expected: number,     // expected pomodoros
    actual: number        // actual pomodoros
}

here is an example

<%*
if (log.mode == "WORK") {
  if (!log.finished) {
    tR = `🟡 Focused ${log.task.name} ${log.duration} / ${log.session} minutes`;
  } else {
    tR = `🍅 Focused ${log.task.name} ${log.duration} minutes`;
  }
} else {
  tR = `☕️ Took a break from ${log.begin.format("HH:mm")} to ${log.end.format(
    "HH:mm"
  )}`;
}
%>

Examples of Using with DataView

Log Table

This DataView script generates a table showing Pomodoro sessions with their durations, start, and end times.

image

const pages = dv.pages()
const table = dv.markdownTable(['Pomodoro','Duration', 'Begin', 'End'],
pages.file.lists
.filter(item=>item.pomodoro)
.sort(item => item.end, 'desc')
.map(item=> {

    return [item.pomodoro, `${item.duration.as('minutes')} m`, item.begin, item.end]
})
)
dv.paragraph(table)

Summary View

This DataView script presents a summary of Pomodoro sessions, categorized by date.

image

const pages = dv.pages();
const emoji = "🍅";
dv.table(
  ["Date", "Pomodoros", "Total"],
  pages.file.lists
    .filter((item) => item?.pomodoro == "WORK")
    .groupBy((item) => {
      if (item.end && item.end.length >= 10) {
        return item.end.substring(0, 10);
      } else {
        return "Unknown Date";
      }
    })
    .map((group) => {
      let sum = 0;
      group.rows.forEach((row) => (sum += row.duration.as("minutes")));
      return [
        group.key,
        group.rows.length > 5
          ? `${emoji}  ${group.rows.length}`
          : `${emoji.repeat(group.rows.length)}`,
        `${sum} min`,
      ];
    })
)

CSS Variables

Variable Default
--pomodoro-timer-color var(--text-faint)
--pomodoro-timer-elapsed-color var(--color-green)
--pomodoro-timer-text-color var(--text-normal)
--pomodoro-timer-dot-color var(--color-ted)

FAQ

  1. How to Switch the Session

To switch sessions, simply click on the Work/Break label displayed on the timer.

  1. How to completely disable Break sessions

You can adjust the break interval setting to 0, this will turn off Break sessions.


BuyMeACoffee

Extension points exported contracts — how you extend this code

TaskDeserializer (Interface)
(no doc) [2 implementers]
src/serializer/index.ts
App (Interface)
(no doc)
src/global.d.ts
Settings (Interface)
(no doc)
src/Settings.ts
DefaultTaskSerializerSymbols (Interface)
(no doc)
src/serializer/DefaultTaskSerializer.ts
TaskComponents (Interface)
(no doc)
src/serializer/TaskModels.ts

Core symbols most depended-on inside this repo

getSettings
called by 19
src/main.ts
toInlineFieldRegex
called by 10
src/utils.ts
openFile
called by 3
src/TaskTracker.ts
createLogContext
called by 2
src/Timer.ts
start
called by 2
src/Timer.ts
endSession
called by 2
src/Timer.ts
pause
called by 2
src/Timer.ts
playAudio
called by 2
src/Timer.ts

Shape

Method 62
Class 20
Function 14
Interface 5
Enum 1

Languages

TypeScript100%

Modules by API surface

src/Timer.ts19 symbols
src/TaskTracker.ts18 symbols
src/utils.ts10 symbols
src/Tasks.ts8 symbols
src/TimerView.ts7 symbols
src/Settings.ts7 symbols
src/Logger.ts7 symbols
src/serializer/DefaultTaskSerializer.ts6 symbols
src/main.ts6 symbols
src/serializer/TaskModels.ts4 symbols
src/serializer/DataviewTaskSerializer.ts4 symbols
src/serializer/index.ts2 symbols

For agents

$ claude mcp add obsidian-pomodoro-timer \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page