Overview
The jarvis-config crate provides Jarvis’s configuration system:
TOML-based configuration with sensible defaults
Theme system with built-in themes
Live reload via file watcher
Full validation
Plugin discovery
Quick Start
use jarvis_config :: {load_config, config_to_json};
let config = load_config () . expect ( "failed to load config" );
let json = config_to_json ( & config );
println! ( "{}" , json );
Core Functions
load_config
Loads configuration from the platform default path.
use jarvis_config :: load_config;
use jarvis_common :: ConfigError ;
fn main () -> Result <(), ConfigError > {
let config = load_config () ? ;
println! ( "Theme: {}" , config . theme . name);
Ok (())
}
This function:
Loads config.toml from the OS config directory
Creates a default config if none exists
Applies the selected theme
Discovers local plugins
Validates the result
config_to_json
Serializes a config to pretty-printed JSON.
use jarvis_config :: {load_config, config_to_json};
let config = load_config () ? ;
let json = config_to_json ( & config );
Configuration Schema
JarvisConfig
Root configuration struct.
All fields use serde(default) so partial configs work correctly. Theme selection and overrides.
Font family, size, and rendering.
Terminal emulator settings.
Shell program and environment.
Window decorations and behavior.
effects
EffectsSchemaConfig
required
Visual effects (bloom, scanlines, etc.).
Panel layout and spacing.
Opacity for various UI elements.
Background mode (hex grid, solid, image).
Audio visualizer settings.
Boot animation and startup behavior.
Livechat server settings.
Presence/social settings.
performance
PerformanceConfig
required
GPU and rendering performance.
Logging level and file output.
Experimental and developer settings.
Auto-open panels on startup.
Constants
Current config schema version. Always 1.
Theme System
Built-in Themes
use jarvis_config :: BUILT_IN_THEMES ;
for theme_name in BUILT_IN_THEMES {
println! ( "Theme: {}" , theme_name );
}
Built-in themes:
jarvis-dark (default)
catppuccin-mocha
catppuccin-macchiato
catppuccin-frappe
catppuccin-latte
tokyo-night
dracula
nord
solarized-dark
solarized-light
Theme Overrides
use jarvis_config :: ThemeOverrides ;
let overrides = ThemeOverrides {
primary : Some ( "#ff0000" . to_string ()),
background : Some ( "#000000" . to_string ()),
.. Default :: default ()
};
Live Reload
ConfigWatcher
Watches the config file for changes and reloads automatically.
use jarvis_config :: ConfigWatcher ;
let watcher = ConfigWatcher :: new () ? ;
loop {
if let Some ( new_config ) = watcher . check_for_changes () {
println! ( "Config reloaded!" );
// Apply new config
}
}
ReloadManager
Manages config reloading with debouncing.
use jarvis_config :: ReloadManager ;
let mut manager = ReloadManager :: new ();
manager . watch ( config_path ) ? ;
Saving Configuration
save_config
Saves config to the default platform path.
use jarvis_config :: { JarvisConfig , save_config};
let config = JarvisConfig :: default ();
save_config ( & config ) ? ;
save_config_to_path
Saves config to a specific path.
use jarvis_config :: { JarvisConfig , save_config_to_path};
use std :: path :: Path ;
let config = JarvisConfig :: default ();
let path = Path :: new ( "/tmp/jarvis.toml" );
save_config_to_path ( & config , path ) ? ;
Validation
All configs are validated on load.
use jarvis_config :: validation;
validation :: validate ( & config ) ? ;
Validation checks:
Required fields are present
Values are in valid ranges
Color strings are valid hex codes
Keybind syntax is correct
Default Configuration
use jarvis_config :: JarvisConfig ;
let config = JarvisConfig :: default ();
assert_eq! ( config . theme . name, "jarvis-dark" );
assert_eq! ( config . font . family, "Menlo" );
assert_eq! ( config . font . size, 13 );
See the full default configuration in the Configuration Guide .
Usage Example
use jarvis_config :: {load_config, save_config, ConfigError };
fn main () -> Result <(), ConfigError > {
// Load config
let mut config = load_config () ? ;
// Modify settings
config . theme . name = "tokyo-night" . to_string ();
config . font . size = 14 ;
config . colors . primary = "#7aa2f7" . to_string ();
// Save changes
save_config ( & config ) ? ;
println! ( "Config saved!" );
Ok (())
}