Skip to content

Internals

Akshay edited this page Aug 4, 2020 · 3 revisions

This document delves into the internals of dijo.

Files

After its first run, dijo creates three files on your file system, one to record habit data, habit_record.json, one to record auto-habit data, habit_record[auto].json, and one to store the default configuration in, config.toml. Data is saved in a human-readable format: JSON (a lot of work went into this). The config file is stored in TOML.

Data files:

Making changes to these files while dijo is running, is not recommended (dijo will overwrite your changes on save).

  • GNU/Linux: $XDG_DATA_HOME/dijo/*.json
  • MacOS: $HOME/Library/Application Support/rs.nerdypepper.dijo/*.json
  • Win10: {FOLDERID_RoamingAppData}\nerdypepper\dijo\data\*.json

Config files:

You can read more about configuring dijo at the Customization page.

  • GNU/Linux: $XDG_CONFIG_HOME/dijo/config.toml
  • MacOS: $HOME/Library/Application Support/rs.nerdypepper.dijo/config.toml
  • Win10: {FOLDERID_RoamingAppData}\nerdypepper\dijo\config\config.toml

dijo will not run on your computer if it can't find your home directory.

Data format

The general structure of a habit is as follows:

type  :: String,
name  :: String,
goal  :: HabitType,
auto  :: bool,
stats :: Map<Date, HabitType>

HabitType is the type of data to be tracked and it is a bool for bit-type habits and a u32 for counting habits.

File watchers

dijo sets up a file watcher (in the interactive mode), and watches habit_record[auto].json for changes. When changes are made to this file via dijo -c or equivalent, the interactive mode receives an update. However, the change is not reflected immediately because of dijo's event based redrawing. You may force a redraw, and thereby update auto habits by pressing any button on the keyboard.