use std::path::PathBuf;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct ClocksConfig {
pub zones: Vec<ClockZone>,
pub time_format: String,
pub date_format: String,
pub show_offset: bool,
pub show_seconds: bool,
}
impl Default for ClocksConfig {
fn default() -> Self {
Self {
zones: vec![
ClockZone {
label: "Local".into(),
timezone: "local".into(),
},
ClockZone {
label: "UTC".into(),
timezone: "UTC".into(),
},
ClockZone {
label: "London".into(),
timezone: "Europe/London".into(),
},
ClockZone {
label: "Tokyo".into(),
timezone: "Asia/Tokyo".into(),
},
],
time_format: "%H:%M:%S".into(),
date_format: "%A %d %B".into(),
show_offset: true,
show_seconds: true,
}
}
}
#[derive(Debug, Clone, Deserialize, serde::Serialize, Default)]
#[serde(default, deny_unknown_fields)]
pub struct ClockZone {
pub label: String,
pub timezone: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct WeatherConfig {
pub location: String,
pub latitude: Option<f64>,
pub longitude: Option<f64>,
pub units: String,
pub forecast_hours: u8,
pub refresh_minutes: u64,
}
impl Default for WeatherConfig {
fn default() -> Self {
Self {
location: "Boston, Massachusetts".into(),
latitude: None,
longitude: None,
units: "imperial".into(),
forecast_hours: 8,
refresh_minutes: 30,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct TodoConfig {
pub file: Option<PathBuf>,
pub show_completed: bool,
pub sort: String,
pub date_format: String,
pub horizon_days: u32,
}
impl Default for TodoConfig {
fn default() -> Self {
Self {
file: None,
show_completed: false,
sort: "smart".into(),
date_format: "%a %d %b".into(),
horizon_days: 0,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct StocksConfig {
pub symbols: Vec<String>,
pub file: Option<PathBuf>,
pub source: String,
pub refresh_secs: u64,
pub stagger_ms: u64,
pub show_sparkline: bool,
}
impl Default for StocksConfig {
fn default() -> Self {
Self {
symbols: vec!["AAPL".into(), "MSFT".into(), "^GSPC".into()],
file: None,
source: "yahoo".to_string(),
refresh_secs: 120,
stagger_ms: 400,
show_sparkline: true,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct NotesConfig {
pub file: Option<PathBuf>,
pub date_format: String,
pub preview: String,
}
impl Default for NotesConfig {
fn default() -> Self {
Self {
file: None,
date_format: "%d %b".to_string(),
preview: "below".to_string(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct AgendaConfig {
pub file: Option<PathBuf>,
pub days: u16,
pub show_location: bool,
pub refresh_secs: u64,
}
impl Default for AgendaConfig {
fn default() -> Self {
Self {
file: None,
days: 7,
show_location: true,
refresh_secs: 60,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct CalendarConfig {
pub months: u8,
pub week_starts: String,
}
impl Default for CalendarConfig {
fn default() -> Self {
Self {
months: 2,
week_starts: "sunday".to_string(),
}
}
}
#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields)]
pub struct PomodoroConfig {
pub focus_minutes: u64,
pub short_break_minutes: u64,
pub long_break_minutes: u64,
pub rounds_before_long_break: u32,
pub auto_start: bool,
pub chime: bool,
pub chime_command: Vec<String>,
}
impl Default for PomodoroConfig {
fn default() -> Self {
Self {
focus_minutes: 25,
short_break_minutes: 5,
long_break_minutes: 15,
rounds_before_long_break: 4,
auto_start: false,
chime: false,
chime_command: Vec::new(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct CpuConfig {
pub history: usize,
pub sample_secs: u64,
pub show_per_core: bool,
pub warn_pct: f32,
pub critical_pct: f32,
}
impl Default for CpuConfig {
fn default() -> Self {
Self {
history: 120,
sample_secs: 2,
show_per_core: true,
warn_pct: 70.0,
critical_pct: 90.0,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct NetworkConfig {
pub interfaces: Vec<String>,
pub history: usize,
pub sample_secs: u64,
}
impl Default for NetworkConfig {
fn default() -> Self {
Self {
interfaces: Vec::new(),
history: 120,
sample_secs: 2,
}
}
}