Expand description
Configuration and XDG persistence.
This module owns two concerns:
Config— the user-facing TOML file at$XDG_CONFIG_HOME/tree-space/config.toml(~/.config/tree-space/config.toml). Every field has a sane default via#[serde(default)], so a minimal file (or none at all) is valid. Those defaults are not written here: they are parsed from the shippeddefault-config.toml(see [builtin]), which is the single source of truth for every default value.SessionState— small runtime state (last opened root) kept in$XDG_STATE_HOME/tree-space/state.toml. Kept separate from the config so that re-exporting the config as a “default” for users stays clean.
The XDG resolution helpers are pure functions over environment-style inputs so they can be tested without mutating process-global environment variables.
Structs§
- Bookmark
- One entry in the bookmarks list: either a directory shortcut (has a
path), a folder grouping nested entries (non-emptyitems), or both. - Bookmarks
Config - The
[bookmarks]options table. Bookmarks are a pane view (a “new panel” showing directory shortcuts to jump from). - Builtin
Entry - A builtin menu item written out in table form, so a label override and/or a
shortcut can be attached to it:
{ action = "Cut", shortcut = "Ctrl+x" }. - Command
Action - A custom command run with the row’s path. The
{path}marker is replaced with the row’s full path;{dir}with the directory itself for a directory row or its parent for a file. With no marker, the path is appended as the final argument. - Config
- Top-level configuration.
- Context
Menu - Configurable per-row context menus.
- Context
Rule - A context-menu rule: rows claimed by any
matchesentry get exactlyitems. Rules are evaluated top-down; the first match wins. - Load
Result - The outcome of loading a config: always a usable config plus an optional problem description for the status bar.
- Pane
Menu - The configurable hamburger (“pane”) menu that opens from the toolbar.
- Panel
Config - Dock/panel configuration. Field-level serde defaults keep a partially
written
[panel]table valid without consultingSelf::default()(which parses the shipped file — see [builtin]). - Session
State - Small runtime state persisted between launches.
- Stylesheet
- The outcome of loading the user stylesheet.
- Submenu
- A nested submenu: a labelled row that opens a child menu of its own items. The items may be anything a top-level menu item can be, including further submenus.
- Theme
Config - The
[theme]section: how the panel gets its colors and fonts. - Tree
Config - Sorting and visibility rules for the tree.
Enums§
- Builtin
Action - A built-in context-menu action: everything the panel can do to a row that
is not a custom command. A
Separatoris only a menu divider; it has no action. - Context
Action - One entry in a context-menu rule:
- Context
Match - Which rows a context-menu rule applies to. Checked in order of rule
precedence:
Dirfirst, then extension, then no-extension, thenRegex/Fallbackfor anything else. - Load
Problem - Why a config could not be loaded cleanly. Absence of a problem (/ defaults used because the file doesn’t exist) is not reported.
- Panel
Layer - The wlr-layer-shell layer the panel lives in.
Bottomkeeps it behind normal windows (the Ormachy/Hyprland “stays out of the way” mode). - Panel
Side - Which edge of the screen the panel docks to.
- Shortcut
Target - The action bound by a shortcut: a builtin, or a custom command that is run against the current row.
- Startup
Root - Where the panel opens when launched without an explicit path argument.
- Style
Source - Which stylesheet
load_stylesheetactually returned. - System
Theme - Which desktop theme
ThemeMode::Systemfollows. Only Omarchy is supported today; more providers may be added later. - Theme
Mode - How the panel is styled.
- Workspace
Move - Where a “move the panel” action should send the panel.
Constants§
- APP_DIR
- The directory name used below all XDG base dirs.
- BOOKMARKS_
FILE - Default name of the bookmarks list file inside
APP_DIR. The config’s[bookmarks] filemay point elsewhere. - CONFIG_
FILE - Name of the config file inside
APP_DIR. - DEFAULT_
STYLESHEET - The shipped default stylesheet, written out beside the config on first launch and used as a fallback when the user’s own is missing or unreadable.
- PANEL_
MAX_ WIDTH - Largest allowed panel width, in pixels.
- PANEL_
MIN_ WIDTH - Smallest allowed panel width, in pixels.
- STATE_
FILE - Name of the state file inside
APP_DIR. - STYLE_
FILE - Name of the user stylesheet inside
APP_DIR.
Functions§
- action_
command - Build a command line for a custom context-menu action on
path. - bookmark_
file_ path - Absolute path of the bookmarks list for the current environment, given the
configured
[bookmarks] file(relative to the config directory, or absolute). - config_
file - Absolute path of the config file for the current environment.
- default_
bookmarks - The bookmark list a fresh install starts with: one entry for the home
directory. Empty only when
$HOMEis unknown. - default_
structure - The theme-independent part of the default stylesheet: every rule, with the
@define-colorpalette stripped off. A system theme prepends its own palette (and font rules) and reuses this structure, so it never needs the user’smain.css. - ensure_
bookmarks_ at ensure_bookmarks_fileagainst an explicit path (tests).- ensure_
bookmarks_ file - Create the bookmarks file for
config(containinglist) on first launch, so the user has something to edit. Never clobbers an existing file; a read-only directory is treated as “nothing to write” (as with the config). - expand_
bookmark_ path - Expand a leading
~in a bookmark path (a no-op for ordinary paths). Stored paths are absolute in practice, but a hand-written~/notesstill works. - expand_
tilde - Expand a leading
~inpathto$HOME. An empty string stays empty. - load_
bookmarks - Read the bookmarks list named by
configfor the current environment. A missing file yieldsdefault_bookmarkswith no problem; an unreadable or unparsable one yields the default list plus the problem, so a broken file never takes the section down. - load_
bookmarks_ from_ path - Read a bookmarks list from an explicit path (tests).
- load_
stylesheet - Load the stylesheet selected by
[theme]. - save_
bookmarks_ to_ path - Write
bookmarkstopathatomically, creating parent directories. MirrorsSessionState::save_to_path: temp file plus rename, so a crash mid-write never truncates the existing list. - state_
file - Absolute path of the state file for the current environment.
- style_
file - Absolute path of the user stylesheet for the current environment.