mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-21 08:11:30 +02:00
This commit introduces a new SocketMessage, ReplaceConfiguration, which attempts to replace a running instance of WindowManager with another created from a (presumably) different komorebi.json file. This will likely be useful for people who have multiple different monitor setups that they connect and disconnect from throughout the day, but definitely needs more testing. An experimental sub-widget which calls this SocketMessage has been added to komorebi-bar to aid with initial testing.
53 lines
1.7 KiB
Rust
53 lines
1.7 KiB
Rust
use crate::battery::Battery;
|
|
use crate::battery::BatteryConfig;
|
|
use crate::date::Date;
|
|
use crate::date::DateConfig;
|
|
use crate::komorebi::Komorebi;
|
|
use crate::komorebi::KomorebiConfig;
|
|
use crate::media::Media;
|
|
use crate::media::MediaConfig;
|
|
use crate::memory::Memory;
|
|
use crate::memory::MemoryConfig;
|
|
use crate::network::Network;
|
|
use crate::network::NetworkConfig;
|
|
use crate::storage::Storage;
|
|
use crate::storage::StorageConfig;
|
|
use crate::time::Time;
|
|
use crate::time::TimeConfig;
|
|
use eframe::egui::Context;
|
|
use eframe::egui::Ui;
|
|
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
pub trait BarWidget {
|
|
fn render(&mut self, ctx: &Context, ui: &mut Ui);
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
|
pub enum WidgetConfig {
|
|
Battery(BatteryConfig),
|
|
Date(DateConfig),
|
|
Komorebi(KomorebiConfig),
|
|
Media(MediaConfig),
|
|
Memory(MemoryConfig),
|
|
Network(NetworkConfig),
|
|
Storage(StorageConfig),
|
|
Time(TimeConfig),
|
|
}
|
|
|
|
impl WidgetConfig {
|
|
pub fn as_boxed_bar_widget(&self) -> Box<dyn BarWidget> {
|
|
match self {
|
|
WidgetConfig::Battery(config) => Box::new(Battery::from(*config)),
|
|
WidgetConfig::Date(config) => Box::new(Date::from(config.clone())),
|
|
WidgetConfig::Komorebi(config) => Box::new(Komorebi::from(config)),
|
|
WidgetConfig::Media(config) => Box::new(Media::from(*config)),
|
|
WidgetConfig::Memory(config) => Box::new(Memory::from(*config)),
|
|
WidgetConfig::Network(config) => Box::new(Network::from(*config)),
|
|
WidgetConfig::Storage(config) => Box::new(Storage::from(*config)),
|
|
WidgetConfig::Time(config) => Box::new(Time::from(config.clone())),
|
|
}
|
|
}
|
|
}
|