Config API¶
The config module manages application configuration.
Overview¶
Configuration is stored in ~/.config/astronomo/config.toml. The module provides typed access to settings with validation and defaults.
API Reference¶
config
¶
Configuration management for Astronomo.
This module provides configuration storage with TOML persistence and sensible defaults.
AppearanceConfig
dataclass
¶
AppearanceConfig(
theme: str = "textual-dark",
syntax_highlighting: bool = True,
show_emoji: bool = True,
max_content_width: int = 80,
show_images: bool = False,
image_quality: str = "medium",
)
Appearance settings.
Attributes:
| Name | Type | Description |
|---|---|---|
theme |
str
|
Textual theme name (e.g., "textual-dark", "nord", "gruvbox") |
syntax_highlighting |
bool
|
Enable syntax highlighting in preformatted blocks |
show_emoji |
bool
|
Display emoji characters (False shows text descriptions) |
max_content_width |
int
|
Maximum width for text content (0 to disable, minimum 40) |
show_images |
bool
|
Display images inline (requires chafapy optional dependency) |
image_quality |
str
|
Image rendering quality ("low", "medium", or "high") |
from_dict
classmethod
¶
Create from dictionary with validation and fallback to defaults.
Source code in src/astronomo/config.py
to_dict
¶
Convert to dictionary for TOML serialization.
Source code in src/astronomo/config.py
BrowsingConfig
dataclass
¶
BrowsingConfig(
home_page: str | None = None,
timeout: int = 30,
max_redirects: int = 5,
identity_prompt: str = "when_ambiguous",
)
Browsing behavior settings.
Attributes:
| Name | Type | Description |
|---|---|---|
home_page |
str | None
|
Default home page URL (None if not set) |
timeout |
int
|
Request timeout in seconds |
max_redirects |
int
|
Maximum number of redirects to follow |
identity_prompt |
str
|
When to show identity selection modal |
from_dict
classmethod
¶
Create from dictionary with validation and fallback to defaults.
Source code in src/astronomo/config.py
to_dict
¶
Convert to dictionary for TOML serialization.
Source code in src/astronomo/config.py
Config
dataclass
¶
Config(
appearance: AppearanceConfig = AppearanceConfig(),
browsing: BrowsingConfig = BrowsingConfig(),
snapshots: SnapshotsConfig = SnapshotsConfig(),
mail: MailConfig = MailConfig(),
)
Root configuration container.
Attributes:
| Name | Type | Description |
|---|---|---|
appearance |
AppearanceConfig
|
Visual appearance settings |
browsing |
BrowsingConfig
|
Browsing behavior settings |
snapshots |
SnapshotsConfig
|
Snapshot settings |
mail |
MailConfig
|
Mail (GMAP) settings |
from_dict
classmethod
¶
Create from dictionary with fallback to defaults for missing sections.
Source code in src/astronomo/config.py
to_dict
¶
Convert to dictionary for TOML serialization.
Source code in src/astronomo/config.py
ConfigManager
¶
Manages application configuration with TOML persistence.
Provides loading and saving of configuration with automatic creation of default config file on first run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path | None
|
Path to the config file. If None, uses the default location (~/.config/astronomo/config.toml) |
None
|
Source code in src/astronomo/config.py
max_content_width
property
¶
Get the configured max content width (0 means disabled).
snapshots_directory
property
¶
Get the configured snapshots directory, or None for default.
syntax_highlighting
property
¶
Get whether syntax highlighting is enabled.
save
¶
Save current configuration to TOML file.
Note: This will overwrite the file without comments. Use sparingly - prefer the commented template format.
Source code in src/astronomo/config.py
Configuration File¶
The default configuration:
[appearance]
theme = "textual-dark"
[browsing]
# home_page = "gemini://geminiprotocol.net/" # Optional
timeout = 30
max_redirects = 5
Example Usage¶
from astronomo.config import ConfigManager
# Load configuration (creates default if needed)
config = ConfigManager()
# Access settings
print(config.theme) # "textual-dark"
print(config.timeout) # 30
print(config.max_redirects) # 5
# Use a custom config path
from pathlib import Path
config = ConfigManager(config_path=Path("~/.my-astronomo-config.toml"))
Available Themes¶
Astronomo uses Textual's built-in themes:
textual-dark(default)textual-lighttextual-ansinordgruvboxtokyo-nightmonokaidraculacatppuccin-mochasolarized-light