banner
DIYgod

Hi, DIYgod

写代码是热爱,写到世界充满爱!
github
twitter
bilibili
telegram
email
steam
playstation
nintendo switch

Life Logging System Based on Obsidian

As mentioned in my 2020 Year-End Summary, I have been using Notion to write bullet journal notes, and now it has changed a bit. Now let's take a look at my current life recording system.

Diary

image

Weekly Journal and Monthly Journal

image

Yearly Journal

image

Original Notion Bullet Journal

image

Thanks to the powerful automation capabilities and high degree of freedom of Obsidian, daily/weekly/monthly/yearly notes are automatically generated using preset templates and are interconnected. There are very few parts that need to be manually processed.

All files have been uploaded to GitHub: https://github.com/DIYgod/DIYgod-Obsidian-Starter, including themes, plugins, configuration files, custom styles, template files, sample files, etc. This is just an example. Please modify it according to your actual situation.

These things may seem a bit complicated at first glance, but they are actually very simple to use, and they have a high degree of freedom and extensibility. Let me explain in detail below.

Structure#

The directory structure is shown in the left sidebar of the diary diagram.

├── OKR.md
└── Journal
    └── 2022
        ├── W1
        |   └── 2022-01-01.md
        |   └── 2022-W1.md
        ├── 2022-01.md
        └── 2022.md

Every day, a diary file YYYY-MM-DD.md will be automatically generated in the folder of the current week. Every week, a new week folder [W]ww and a weekly journal YYYY-[W]ww.md will be automatically created. Every month, a monthly journal YYYY-MM.md will be automatically generated. Every year, a new year folder YYYY and a yearly journal YYYY.md will be automatically created (Correction: Not automatic, still need to manually trigger through the command palette).

The content of these files is also preset templates, and the date, OKR scores, and charts for this period are automatically filled in. It even leaves a space for recording the status and dynamics of the day.

There is an OKR file outside, which is updated approximately every six months. It records the life goals for this half year. Some goals require continuous effort every day. The diary system is largely built around these goals.

The directory structure is mainly implemented through Periodic Notes, and the templates are mainly implemented through Templater and Dataview and the core plugin Templates.

Diary#

image

Info#

Info is the automatically generated information for the day, including links to the yearly, monthly, and weekly journals and OKR, as well as information about location, weather, moon phase, etc.

The location, weather, and moon phase information are obtained through the system command function of Templater.

Get location and weather:

curl wttr.in/"$(curl -s --header "user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" https://api.ip.sb/geoip | /opt/homebrew/bin/jq -r ".city" | sed 's/ /%20/')"\?format="%l+%c%t"

Get moon phase:

curl wttr.in/"$(curl -s --header "user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" https://api.ip.sb/geoip | /opt/homebrew/bin/jq -r ".city" | sed 's/ /%20/')"\?format="%m"

OKR Tracker#

OKR Tracker records the completion status of the current stage of OKR for the day. For example, Sleep:: 10.3 represents sleeping for 10.3 hours today, and Healthy Eating:: 5 represents eating healthily today. :: is the Dataview syntax, which adds the following property to the current page:

page = {
    ...
    "Sleep": 10.3,
    "Healthy Eating": 5,
}

This makes it convenient to analyze and process in the weekly, monthly, and yearly journals.

Under O1 KR2, there is a special list that displays the Toggl Track data for the day through an API. Toggl Track is a time tracking application that records the time I spend on various tasks every day, such as watching anime, browsing Bilibili, working, etc. These data can also reflect whether my productivity meets expectations.

Notes#

This is where the actual diary is written. Most of them are some casual records to make up for my naturally bad memory. Occasionally, I will also write down some thoughts.

Weekly and Monthly Journals#

image

Journal List#

Journal List is a list of all diaries for the current week/month, implemented through Dataview.

Get all diaries:

// Week
window.pages = dv.pages(`"${dv.current().file.folder}"`).where(p => p.file.name.match(new RegExp(`${dv.current().file.name.split('-')[0]}-\\d{2}-\\d{2}`))).sort(p => p.file.name);

// Month
window.pages = dv.pages().where(p => p.file.name.match(new RegExp(`${dv.current().file.name}-\\d{2}`))).sort(p => p.file.name);

Render the list:

dv.paragraph(window.pages.file.link.join(', '))

Summary#

This is where I summarize and reflect on the month. It corresponds to the Notes in the diary.

OKR Tracker#

Process and analyze the OKR data in all diaries here, and finally generate a score. It corresponds to the OKR Tracker in the diary.

It is implemented through Dataview. Taking sleep as an example, sleep of ≥ 6.5 hours and ≤ 8.5 hours is considered effective sleep, and the percentage of effective sleep days to total days is the score.

let count = 0;
let total = 0;
for (let page of window.pages) {
    if (page['Sleep']) {
        count++;
        if (page['Sleep'] >= 6.5 && page['Sleep'] <= 8.5) {
            total++;
        }
    }
}
const score = (total / count * 100).toFixed(2);
dv.el('div', score + '%', {
    cls: score > 80 ? 'score-class1' : score > 50 ? 'score-class2' : 'score-class3'
});

Then add some CSS. Scores above 80 are displayed in green, scores between 50 and 80 are displayed in yellow, and scores below 50 are displayed in red. This makes it clear to see the sleep situation of the current week/month. The image shows the yellow range, which is not ideal but acceptable. I need to pay more attention next month.

Statistics#

Generate sleep and exercise data charts here. It is clear that the sleep duration is quite unstable, and the number of exercise days and duration is very small.

The charts are drawn using Obsidian Charts. The sleep statistics chart code is as follows:

const times = [];
for (let page of window.pages) {
    times.push(page['Sleep']);
}

const chartData = {
    type: 'line',
    data: {
        labels: window.pages.file.name.array(),
        datasets: [{
            label: 'Sleep Time',
            data: times,
            pointBackgroundColor: '#6c40d6',
            borderColor: '#6c40d65c',
            tension: 0.4,
            spanGaps: true,
        }],
    },
    options: {
        scales: {
            y: {
                type: 'linear',
                min: 2,
                max: 13
            }
        }
    }
}

window.renderChart(chartData, this.container);

Finance#

A pie chart of financial data for the month, generated by MoneyWiz.

Yearly Journal#

image

The yearly journal is similar to the weekly and monthly journals, but by expanding the time scale, many new useful conclusions can be drawn.

For example, the same sleep and exercise statistics chart can show that my sleep started to get out of control at the end of May, and during this period, exercise was also interrupted, and it gradually improved from mid-June.

There is also a new weight and body fat statistics chart, which shows that my weight and body fat are steadily decreasing, indicating a significant improvement in health.

The yearly journal also introduces a new type of heatmap, which records the days when goals are achieved. It is drawn using Heatmap Calendar. Taking sleep as an example:

const calendarData = { 
    entries: [],
}

const pages = window.pages
    .where(p => p.Sleep && p.Sleep >= 6.5 && p.Sleep <= 8.5)
    .sort(p => p.file.name);

for(let page of pages){ 
    calendarData.entries.push({
        date: page.file.name,
        intensity: page.Sleep,
    })
}

renderHeatmapCalendar(this.container, calendarData);

Limitations#

Bullet journals have an important task list module, as shown in the screenshot of the bullet journal above. I used to write the tasks for the week in advance in the notes, but now the diaries are automatically generated for the day, so I cannot plan in advance. Therefore, I have switched to using TickTick to manage the task list. TickTick is also very useful, but it lacks the integration with the diary. Manually adding tasks will cause a lot of duplicate work, which is not very pleasant.

Finally, it is important to note that even with such a life management system, it does not mean that life will always go as planned. Just like the sleep loss event mentioned above at the end of May, once relaxation and loss of control occur, it will still happen. The notes will tell me that life is out of control, but how to get back on track and catch up with the OKR still depends on self-control and regular summarization, reflection, and improvement.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.