mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-01-11 06:30:24 +01:00
feat(bar): make explicit monitor config optional
This commit makes the monitor configuration option for the komorebi-bar optional, defaulting to index 0.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.40/schema.bar.json",
|
||||
"monitor": 0,
|
||||
"font_family": "JetBrains Mono",
|
||||
"theme": {
|
||||
"palette": "Base16",
|
||||
|
||||
@@ -453,10 +453,11 @@ impl Komobar {
|
||||
self.right_widgets = right_widgets;
|
||||
|
||||
let (usr_monitor_index, config_work_area_offset) = match &self.config.monitor {
|
||||
MonitorConfigOrIndex::MonitorConfig(monitor_config) => {
|
||||
Some(MonitorConfigOrIndex::MonitorConfig(monitor_config)) => {
|
||||
(monitor_config.index, monitor_config.work_area_offset)
|
||||
}
|
||||
MonitorConfigOrIndex::Index(idx) => (*idx, None),
|
||||
Some(MonitorConfigOrIndex::Index(idx)) => (*idx, None),
|
||||
None => (0, None),
|
||||
};
|
||||
|
||||
let mapped_info = self.monitor_info.as_ref().map(|info| {
|
||||
@@ -866,9 +867,13 @@ impl eframe::App for Komobar {
|
||||
Ok(KomorebiEvent::Notification(notification)) => {
|
||||
let state = ¬ification.state;
|
||||
let usr_monitor_index = match &self.config.monitor {
|
||||
MonitorConfigOrIndex::MonitorConfig(monitor_config) => monitor_config.index,
|
||||
MonitorConfigOrIndex::Index(idx) => *idx,
|
||||
Some(MonitorConfigOrIndex::MonitorConfig(monitor_config)) => {
|
||||
monitor_config.index
|
||||
}
|
||||
Some(MonitorConfigOrIndex::Index(idx)) => *idx,
|
||||
None => 0,
|
||||
};
|
||||
|
||||
let monitor_index = state.monitor_usr_idx_map.get(&usr_monitor_index).copied();
|
||||
self.monitor_index = monitor_index;
|
||||
let mut should_apply_config = false;
|
||||
|
||||
@@ -76,7 +76,8 @@ pub struct KomobarConfig {
|
||||
/// Frame options (see: https://docs.rs/egui/latest/egui/containers/frame/struct.Frame.html)
|
||||
pub frame: Option<FrameConfig>,
|
||||
/// The monitor index or the full monitor options
|
||||
pub monitor: MonitorConfigOrIndex,
|
||||
#[cfg_attr(feature = "schemars", schemars(extend("default" = MonitorConfigOrIndex::Index(0))))]
|
||||
pub monitor: Option<MonitorConfigOrIndex>,
|
||||
/// Font family
|
||||
pub font_family: Option<String>,
|
||||
/// Font size
|
||||
|
||||
@@ -216,11 +216,13 @@ fn main() -> color_eyre::Result<()> {
|
||||
)?)?;
|
||||
|
||||
let (usr_monitor_index, work_area_offset) = match &config.monitor {
|
||||
MonitorConfigOrIndex::MonitorConfig(monitor_config) => {
|
||||
Some(MonitorConfigOrIndex::MonitorConfig(monitor_config)) => {
|
||||
(monitor_config.index, monitor_config.work_area_offset)
|
||||
}
|
||||
MonitorConfigOrIndex::Index(idx) => (*idx, None),
|
||||
Some(MonitorConfigOrIndex::Index(idx)) => (*idx, None),
|
||||
None => (0, None),
|
||||
};
|
||||
|
||||
let monitor_index = state
|
||||
.monitor_usr_idx_map
|
||||
.get(&usr_monitor_index)
|
||||
|
||||
@@ -99,8 +99,9 @@ impl RenderExt for &KomobarConfig {
|
||||
icon_font_id.size *= icon_scale.unwrap_or(1.4).clamp(1.0, 2.0);
|
||||
|
||||
let monitor_idx = match &self.monitor {
|
||||
MonitorConfigOrIndex::MonitorConfig(monitor_config) => monitor_config.index,
|
||||
MonitorConfigOrIndex::Index(idx) => *idx,
|
||||
Some(MonitorConfigOrIndex::MonitorConfig(monitor_config)) => monitor_config.index,
|
||||
Some(MonitorConfigOrIndex::Index(idx)) => *idx,
|
||||
None => 0,
|
||||
};
|
||||
|
||||
// check if any of the alignments have a komorebi widget with the workspace set to show all icons
|
||||
|
||||
Reference in New Issue
Block a user