Skip to content

OSM needs config file(s), and needs to find obsidian.json #11

@peterkaminski

Description

@peterkaminski

@dgou, wdyt?

Considering #7, #8, and #9:

  1. OSM needs to find obsidian.json, and there are well-known typical places on each platform.
  2. Sometimes obsidian.json is not in the typical place, so there needs to be a way to read the right place from a config file (along with environment).
  3. OSM needs to know what directories and files to include and exclude for its operation, so we need a config file for that.

Usability-wise, I would like:

  • OSM works for most people without configuration.
  • OSM is easy to configure if you need to configure it.
  • If you copy just osm.py someplace else (e.g. /usr/local/bin or whatever) and don't copy any other doc or config file, it still works for most people.
  • If we have configuration data, it happens in one file, not multiple files.

Therefore, my proposal:

  • Look up the typical Obsidian root directory based on platform and pathlib.Path.home(), similar to Qt's QStandardPaths documentation. (N.B., that code is for a writable dir, not the config dir, so the Windows and Linux paths need to be corrected).
  • Override the typical Obsidian root directory with a config file and environment variable.
  • Use one config file, rather than multiple, which means we need to use YAML or TOML (or something worse) rather than one text file per config section.

Massive Wiki Builder uses the --config/-c flag to specify the config file, typically named osm.yaml, but could be any path/filename:

./osm.py -c /path/to/my/osm-config-file.yml [commands]

So, use --config/-c unless there's clearly a problem with that.

Once we have a config file, we might find other uses for it, too, and any additional config data would be added to that one file, rather than adding more text config files.

Prototype of a YAML config file (TOML would be similar but different):

obsidian_root_directory: "/home/peterkaminski.var/app/md.obsidian.Obsidian/config/obsidian"

files_to_copy:
  - include: "."
  - exclude: "*.json"
  - exclude: "workspace*"
  - include: "snippets"
  - exclude: "plugins"
  - include: "plugins/buttons"
  - exclude: "plugins/buttons/styles.css"
  - include: "plugins/tag-wrangler"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions