-
Notifications
You must be signed in to change notification settings - Fork 0
Theming System
Relevant source files
The following files were used as context for generating this wiki page:
The Aurora theming system provides an end-to-end pipeline for dynamic UI customization. It supports hot-reloading from a configuration file, allowing the user to change the entire color palette of the application without restarting the daemon or the player.
The theming lifecycle spans across the daemon, the protocol, and the GUI frontend.
-
Storage: Themes are defined in
~/.config/aurora-player/config.toml. -
Detection: The
theme_threadin the daemon watches this file for changes. -
Broadcast: Upon change, the daemon sends a
Response::ThemeIPC message to all connected clients. - Conversion: The player receives hex strings and converts them to Slint-compatible color objects.
-
Application: A global
Themesingleton in Slint propagates these colors to all UI components.
The following diagram illustrates how a change in the configuration file propagates through the system entities.
Theme Propagation Flow
graph TD
subgraph "Filesystem Space"
CONFIG["config.toml"]
end
subgraph "aurora-daemon (Natural Language Space)"
WATCHER["theme_thread::init"]
GET_CFG["theme_thread::get_config"]
STATE["StateStruct.theme"]
end
subgraph "aurora-protocol"
RES_THEME["Response::Theme(Theme)"]
end
subgraph "aurora-player (Code Entity Space)"
IFACE["interface.rs: unix_recver"]
HEX_CONV["interface.rs: hex_to_u8"]
SLINT_THEME["Types.slint: global Theme"]
end
CONFIG -.->|"inotify event"| WATCHER
WATCHER --> GET_CFG
GET_CFG -->|"TOML Parse"| STATE
STATE -->|"Broadcast"| RES_THEME
RES_THEME --> IFACE
IFACE --> HEX_CONV
HEX_CONV -->|"aurora.set_Theme_..."| SLINT_THEME
Sources: daemon/src/theme_thread.rs:32-54, app/src/interface.rs:58-72, app/src/interface.rs:191-204
The theme is controlled by a TOML file located at $XDG_CONFIG_HOME/aurora-player/config.toml daemon/src/theme_thread.rs:19-22. If the file is missing, the system falls back to a "Gruvbox-inspired" hardcoded default daemon/src/theme_thread.rs:7-18.
The configuration defines 10 specific color keys that map to the UI's functional areas:
| Key | Description | Typical Use Case |
|---|---|---|
bgd0 |
Deepest Background | Main window root background |
bgd1 |
Secondary Background | Active tab, sidebar elements |
bgd2 |
Surface Background | Cards, search bars, containers |
bgd3 |
Elevated Background | Hover states, borders |
bgd4 |
Highlight Background | Pressed states, active accents |
txt1 |
Primary Text | Song titles, active labels |
txt2 |
Secondary Text | Artist names, durations, inactive labels |
acct |
Accent | Icons, sliders, active tab text |
srch |
Search Background | Specific background for the search input |
btns |
Button/Icon color | Standard color for transport controls |
The project includes several bundled presets within the themes/config.toml file, including:
- MavenBlack: High contrast pitch black and emerald green themes/config.toml:15-24.
- Cyberpunk: Dark navy with neon pink accents themes/config.toml:2-11.
- Forest: Earthy greens and off-white text themes/config.toml:41-50.
- Synth: Deep purples and bright pinks themes/config.toml:54-63.
Sources: themes/config.toml:1-77, daemon/src/theme_thread.rs:6-18
The daemon manages the theme via a dedicated background thread initialized during startup.
The theme_thread::init function uses the notify crate to establish a recursive watcher on the configuration directory daemon/src/theme_thread.rs:37-39. It listens for Create, Modify, or Remove events daemon/src/theme_thread.rs:43.
When an event is detected:
-
get_config()is called to re-read the TOML file daemon/src/theme_thread.rs:44. - The
StateStructis updated with the newThemestruct daemon/src/theme_thread.rs:45. -
helpers::send_to_allbroadcasts the new theme to all connected Unix socket clients viaResponse::Theme(theme)daemon/src/theme_thread.rs:46.
Sources: daemon/src/theme_thread.rs:32-54, daemon/src/theme_thread.rs:6-30
The player application receives the theme as a set of hex strings (e.g., "#cba6f7") and must apply them to the Slint runtime.
Slint requires a slint::Color type, whereas the protocol transmits strings. The hex_to_u8 utility function handles this conversion:
- It strips the
#prefix app/src/interface.rs:21. - It parses the R, G, and B components using
u8::from_str_radixapp/src/interface.rs:23-25. - It returns a
slint::Color::from_rgb_u8object app/src/interface.rs:27.
Within the unix_recver loop, the Response::Theme(theme) variant triggers an update to the Slint global singleton app/src/interface.rs:191-204. This is executed within app.upgrade_in_event_loop to ensure thread safety when interacting with the UI app/src/interface.rs:192.
Code Mapping: IPC Response to Slint Global
graph LR
subgraph "Response::Theme Handler"
direction TB
A["theme.bgd0"] -->|"hex_to_u8"| B["aurora.set_Theme_bgd0"]
C["theme.acct"] -->|"hex_to_u8"| D["aurora.set_Theme_acct"]
E["theme.txt1"] -->|"hex_to_u8"| F["aurora.set_Theme_txt1"]
end
B --> G["Types.slint: global Theme"]
D --> G
F --> G
Sources: app/src/interface.rs:20-28, app/src/interface.rs:191-204
The UI components do not define their own colors. Instead, they bind to properties of the global Theme declared in Types.slint.
The Theme global contains in-out properties for every color key defined in the protocol app/ui/Types.slint:40-51.
UI components import the Theme and use its properties for backgrounds, text colors, and animations. For example, the TabButton changes its background and text color based on whether it is active, using Theme.bgd1, Theme.bgd2, and Theme.acct app/ui/TabSelectorView.slint:8-16.
Because Slint properties are reactive, calling aurora.set_Theme_bgd1(...) from Rust automatically triggers a re-render of every component referencing that property across the entire application.
Sources: app/ui/Types.slint:40-51, app/ui/TabSelectorView.slint:1-16
Overview
aurora-daemon
- Background Service
- Startup & State Init
- Request Handlers & Dispatch
- Playback Engine & Audio
- Library Indexing & Watching
- Playlists, Liked & History
- Background Threads
aurora-protocol
aurora-player
Reference