Skip to content
This repository was archived by the owner on Mar 29, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions src/config/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{collections::HashMap, fs, path::PathBuf};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Config {
#[serde(default)]
pub bar: BarConfig,
pub bars: std::collections::HashMap<String, BarConfig>,

#[serde(default)]
pub modules_left: Vec<String>,
Expand Down Expand Up @@ -50,17 +50,35 @@ pub struct Config {
pub revealers: std::collections::HashMap<String, RevealerConfig>,
}

/* #[derive(Debug, Deserialize, Serialize, Clone)]
pub struct BarsConfig {
#[serde(default)]
pub bars: std::collections::HashMap<String, BarConfig>,
} */

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct BarConfig {
#[serde(default)]
pub modules_left: Option<Vec<String>>,

#[serde(default)]
pub modules_center: Option<Vec<String>>,

#[serde(default)]
pub modules_right: Option<Vec<String>>,

#[serde(default = "default_height")]
pub height: u32,

#[serde(default = "default_position")]
#[serde(default = "default_layer_and_position")]
pub position: String,

#[serde(default = "default_layer")]
#[serde(default = "default_layer_and_position")]
pub layer: String,

#[serde(default = "default_namespace")]
pub namespace: String,

#[serde(default = "default_spacing")]
pub spacing: i32,
}
Expand Down Expand Up @@ -352,11 +370,11 @@ pub struct RevealerConfig {
fn default_height() -> u32 {
30
}
fn default_position() -> String {
"top".to_string()
fn default_layer_and_position() -> String {
String::from("top")
}
fn default_layer() -> String {
"top".to_string()
fn default_namespace() -> String {
String::from("bar-container")
}
fn default_spacing() -> i32 {
10
Expand All @@ -372,9 +390,13 @@ fn default_command() -> String {
impl Default for BarConfig {
fn default() -> Self {
Self {
modules_left: default_modules(),
modules_center: default_modules(),
modules_right: default_modules(),
height: default_height(),
position: default_position(),
layer: default_layer(),
position: default_layer_and_position(),
layer: default_layer_and_position(),
namespace: default_namespace(),
spacing: default_spacing(),
}
}
Expand Down Expand Up @@ -712,13 +734,11 @@ impl Config {
let example = r#"
# Riftbar Configuration

# Module positions (MUST be at root level, BEFORE any [sections])
[bar.main]
modules_left = ["box/left"]
modules_center = ["hyprland/workspaces"]
modules_right = ["box/right"]

[bar]
position = "top" # top, bottom
position = "top" # top, bottom, left, right
layer = "top" # background, bottom, top, overlay

# Clock module configuration
Expand Down Expand Up @@ -865,3 +885,7 @@ fn optional_format() -> Option<String> {
fn default_icons() -> Option<HashMap<String, String>> {
None
}

fn default_modules() -> Option<Vec<String>> {
Some(Vec::from([String::new()]))
}
Loading
Loading