perf(cargo): make schemars derives optional

This commit makes all schemars::JsonSchema derives optional. After
analyzing the output of cargo build timings and llvm-lines, it was clear
that the majority of the 2m+ incremental dev build times was taken up by
codegen, and the majority of it by schemars.

Developers can now run cargo commands with --no-default-features to
disable schemars::JsonSchema codegen, and all justfile commands have
been updated to take this flag by default, with the exception of the
jsonschema target, which will compile with all derives required to
export the various jsonschema files.

Incremental dev build times for komorebi.exe on my machine are now at
around ~18s, while clean dev build times for the entire workspace are at
around ~1m.
This commit is contained in:
LGUG2Z
2025-03-03 14:11:05 -08:00
committed by Jeezy
parent a837fea40c
commit b53de81754
50 changed files with 377 additions and 467 deletions
-13
View File
@@ -72,16 +72,3 @@ features = [
"Media", "Media",
"Media_Control" "Media_Control"
] ]
[profile.dev-jeezy]
inherits = "dev"
debug = false
opt-level = 1
[profile.dev-jeezy.package."*"]
opt-level = 3
[profile.release-jeezy]
inherits = "release"
incremental = true
codegen-units = 256
+13 -4
View File
@@ -19,22 +19,31 @@ install-targets *targets:
"{{ targets }}" -split ' ' | ForEach-Object { just install-target $_ } "{{ targets }}" -split ' ' | ForEach-Object { just install-target $_ }
install-target target: install-target target:
cargo +stable install --path {{ target }} --locked --no-default-features
install-targets-with-jsonschema *targets:
"{{ targets }}" -split ' ' | ForEach-Object { just install-target-with-jsonschema $_ }
install-target-with-jsonschema target:
cargo +stable install --path {{ target }} --locked cargo +stable install --path {{ target }} --locked
install: install:
just install-targets komorebic komorebic-no-console komorebi komorebi-bar komorebi-gui just install-targets komorebic komorebic-no-console komorebi komorebi-bar komorebi-gui
install-with-jsonschema:
just install-targets-with-jsonschema komorebic komorebic-no-console komorebi komorebi-bar komorebi-gui
build-targets *targets: build-targets *targets:
"{{ targets }}" -split ' ' | ForEach-Object { just build-target $_ } "{{ targets }}" -split ' ' | ForEach-Object { just build-target $_ }
build-target target: build-target target:
cargo +stable build --package {{ target }} --locked --profile release-jeezy cargo +stable build --package {{ target }} --locked --release --no-default-features
build: build:
just build-targets komorebic komorebic-no-console komorebi komorebi-bar komorebi-gui just build-targets komorebic komorebic-no-console komorebi komorebi-bar komorebi-gui
copy-target target: copy-target target:
cp .\target\release-jeezy\{{ target }}.exe $Env:USERPROFILE\.cargo\bin cp .\target\release\{{ target }}.exe $Env:USERPROFILE\.cargo\bin
copy-targets *targets: copy-targets *targets:
"{{ targets }}" -split ' ' | ForEach-Object { just copy-target $_ } "{{ targets }}" -split ' ' | ForEach-Object { just copy-target $_ }
@@ -46,7 +55,7 @@ copy:
just copy-targets komorebic komorebic-no-console komorebi komorebi-bar komorebi-gui just copy-targets komorebic komorebic-no-console komorebi komorebi-bar komorebi-gui
run target: run target:
cargo +stable run --bin {{ target }} --locked cargo +stable run --bin {{ target }} --locked --no-default-features
warn target $RUST_LOG="warn": warn target $RUST_LOG="warn":
just run {{ target }} just run {{ target }}
@@ -61,7 +70,7 @@ trace target $RUST_LOG="trace":
just run {{ target }} just run {{ target }}
deadlock $RUST_LOG="trace": deadlock $RUST_LOG="trace":
cargo +stable run --bin komorebi --locked --features deadlock_detection cargo +stable run --bin komorebi --locked --no-default-features --features deadlock_detection
docgen: docgen:
cargo run --package komorebic -- docgen cargo run --package komorebic -- docgen
+5 -1
View File
@@ -26,7 +26,7 @@ num-derive = "0.4"
num-traits = "0.2" num-traits = "0.2"
random_word = { version = "0.4", features = ["en"] } random_word = { version = "0.4", features = ["en"] }
reqwest = { version = "0.12", features = ["blocking"] } reqwest = { version = "0.12", features = ["blocking"] }
schemars = { workspace = true } schemars = { workspace = true, optional = true }
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
starship-battery = "0.10" starship-battery = "0.10"
@@ -36,3 +36,7 @@ tracing-subscriber = { workspace = true }
windows = { workspace = true } windows = { workspace = true }
windows-core = { workspace = true } windows-core = { workspace = true }
windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" } windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" }
[features]
default = ["schemars"]
schemars = ["dep:schemars"]
+2 -2
View File
@@ -8,7 +8,6 @@ use eframe::egui::Context;
use eframe::egui::Label; use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use starship_battery::units::ratio::percent; use starship_battery::units::ratio::percent;
@@ -18,7 +17,8 @@ use std::process::Command;
use std::time::Duration; use std::time::Duration;
use std::time::Instant; use std::time::Instant;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct BatteryConfig { pub struct BatteryConfig {
/// Enable the Battery widget /// Enable the Battery widget
pub enable: bool, pub enable: bool,
+29 -17
View File
@@ -6,13 +6,13 @@ use eframe::egui::TextBuffer;
use eframe::egui::Vec2; use eframe::egui::Vec2;
use komorebi_client::KomorebiTheme; use komorebi_client::KomorebiTheme;
use komorebi_client::Rect; use komorebi_client::Rect;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
/// The `komorebi.bar.json` configuration file reference for `v0.1.35` /// The `komorebi.bar.json` configuration file reference for `v0.1.35`
pub struct KomobarConfig { pub struct KomobarConfig {
/// Bar height (default: 50) /// Bar height (default: 50)
@@ -136,7 +136,8 @@ impl KomobarConfig {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct PositionConfig { pub struct PositionConfig {
/// The desired starting position of the bar (0,0 = top left of the screen) /// The desired starting position of the bar (0,0 = top left of the screen)
#[serde(alias = "position")] #[serde(alias = "position")]
@@ -146,13 +147,15 @@ pub struct PositionConfig {
pub end: Option<Position>, pub end: Option<Position>,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct FrameConfig { pub struct FrameConfig {
/// Margin inside the painted frame /// Margin inside the painted frame
pub inner_margin: Position, pub inner_margin: Position,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum MonitorConfigOrIndex { pub enum MonitorConfigOrIndex {
/// The monitor index where you want the bar to show /// The monitor index where you want the bar to show
@@ -161,7 +164,8 @@ pub enum MonitorConfigOrIndex {
MonitorConfig(MonitorConfig), MonitorConfig(MonitorConfig),
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct MonitorConfig { pub struct MonitorConfig {
/// Komorebi monitor index of the monitor on which to render the bar /// Komorebi monitor index of the monitor on which to render the bar
pub index: usize, pub index: usize,
@@ -172,7 +176,8 @@ pub struct MonitorConfig {
pub type Padding = SpacingKind; pub type Padding = SpacingKind;
pub type Margin = SpacingKind; pub type Margin = SpacingKind;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
// WARNING: To any developer messing with this code in the future: The order here matters! // WARNING: To any developer messing with this code in the future: The order here matters!
// `Grouped` needs to come last, otherwise serde might mistaken an `IndividualSpacingConfig` for a // `Grouped` needs to come last, otherwise serde might mistaken an `IndividualSpacingConfig` for a
@@ -223,20 +228,23 @@ impl SpacingKind {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct GroupedSpacingConfig { pub struct GroupedSpacingConfig {
pub vertical: Option<GroupedSpacingOptions>, pub vertical: Option<GroupedSpacingOptions>,
pub horizontal: Option<GroupedSpacingOptions>, pub horizontal: Option<GroupedSpacingOptions>,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum GroupedSpacingOptions { pub enum GroupedSpacingOptions {
Symmetrical(f32), Symmetrical(f32),
Split(f32, f32), Split(f32, f32),
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct IndividualSpacingConfig { pub struct IndividualSpacingConfig {
pub top: f32, pub top: f32,
pub bottom: f32, pub bottom: f32,
@@ -338,7 +346,8 @@ impl KomobarConfig {
} }
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Position { pub struct Position {
/// X coordinate /// X coordinate
pub x: f32, pub x: f32,
@@ -364,7 +373,8 @@ impl From<Position> for Pos2 {
} }
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "palette")] #[serde(tag = "palette")]
pub enum KomobarTheme { pub enum KomobarTheme {
/// A theme from catppuccin-egui /// A theme from catppuccin-egui
@@ -400,7 +410,8 @@ impl From<KomorebiTheme> for KomobarTheme {
} }
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum LabelPrefix { pub enum LabelPrefix {
/// Show no prefix /// Show no prefix
None, None,
@@ -412,7 +423,8 @@ pub enum LabelPrefix {
IconAndText, IconAndText,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum DisplayFormat { pub enum DisplayFormat {
/// Show only icon /// Show only icon
Icon, Icon,
@@ -428,7 +440,8 @@ pub enum DisplayFormat {
macro_rules! extend_enum { macro_rules! extend_enum {
($existing_enum:ident, $new_enum:ident, { $($(#[$meta:meta])* $variant:ident),* $(,)? }) => { ($existing_enum:ident, $new_enum:ident, { $($(#[$meta:meta])* $variant:ident),* $(,)? }) => {
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize, schemars::JsonSchema, PartialEq)] #[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum $new_enum { pub enum $new_enum {
// Add new variants // Add new variants
$( $(
@@ -460,12 +473,11 @@ extend_enum!(DisplayFormat, WorkspacesDisplayFormat, {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use serde_json::json; use serde_json::json;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum OriginalDisplayFormat { pub enum OriginalDisplayFormat {
/// Show None Of The Things /// Show None Of The Things
NoneOfTheThings, NoneOfTheThings,
+2 -2
View File
@@ -8,7 +8,6 @@ use eframe::egui::Context;
use eframe::egui::Label; use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::process::Command; use std::process::Command;
@@ -17,7 +16,8 @@ use std::time::Instant;
use sysinfo::RefreshKind; use sysinfo::RefreshKind;
use sysinfo::System; use sysinfo::System;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct CpuConfig { pub struct CpuConfig {
/// Enable the Cpu widget /// Enable the Cpu widget
pub enable: bool, pub enable: bool,
+6 -4
View File
@@ -9,12 +9,12 @@ use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use eframe::egui::WidgetText; use eframe::egui::WidgetText;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
/// Custom format with additive modifiers for integer format specifiers /// Custom format with additive modifiers for integer format specifiers
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct CustomModifiers { pub struct CustomModifiers {
/// Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html) /// Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html)
format: String, format: String,
@@ -55,7 +55,8 @@ impl CustomModifiers {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct DateConfig { pub struct DateConfig {
/// Enable the Date widget /// Enable the Date widget
pub enable: bool, pub enable: bool,
@@ -75,7 +76,8 @@ impl From<DateConfig> for Date {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum DateFormat { pub enum DateFormat {
/// Month/Date/Year format (09/08/24) /// Month/Date/Year format (09/08/24)
MonthDateYear, MonthDateYear,
+2 -2
View File
@@ -8,7 +8,6 @@ use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use eframe::egui::WidgetText; use eframe::egui::WidgetText;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::time::Duration; use std::time::Duration;
@@ -23,7 +22,8 @@ use windows::Win32::UI::WindowsAndMessaging::GetWindowThreadProcessId;
const DEFAULT_DATA_REFRESH_INTERVAL: u64 = 1; const DEFAULT_DATA_REFRESH_INTERVAL: u64 = 1;
const ERROR_TEXT: &str = "Error"; const ERROR_TEXT: &str = "Error";
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct KeyboardConfig { pub struct KeyboardConfig {
/// Enable the Input widget /// Enable the Input widget
pub enable: bool, pub enable: bool,
+12 -7
View File
@@ -37,7 +37,6 @@ use komorebi_client::SocketMessage;
use komorebi_client::Window; use komorebi_client::Window;
use komorebi_client::Workspace; use komorebi_client::Workspace;
use komorebi_client::WorkspaceLayer; use komorebi_client::WorkspaceLayer;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::cell::RefCell; use std::cell::RefCell;
@@ -47,7 +46,8 @@ use std::path::PathBuf;
use std::rc::Rc; use std::rc::Rc;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct KomorebiConfig { pub struct KomorebiConfig {
/// Configure the Workspaces widget /// Configure the Workspaces widget
pub workspaces: Option<KomorebiWorkspacesConfig>, pub workspaces: Option<KomorebiWorkspacesConfig>,
@@ -61,7 +61,8 @@ pub struct KomorebiConfig {
pub configuration_switcher: Option<KomorebiConfigurationSwitcherConfig>, pub configuration_switcher: Option<KomorebiConfigurationSwitcherConfig>,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct KomorebiWorkspacesConfig { pub struct KomorebiWorkspacesConfig {
/// Enable the Komorebi Workspaces widget /// Enable the Komorebi Workspaces widget
pub enable: bool, pub enable: bool,
@@ -71,7 +72,8 @@ pub struct KomorebiWorkspacesConfig {
pub display: Option<WorkspacesDisplayFormat>, pub display: Option<WorkspacesDisplayFormat>,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct KomorebiLayoutConfig { pub struct KomorebiLayoutConfig {
/// Enable the Komorebi Layout widget /// Enable the Komorebi Layout widget
pub enable: bool, pub enable: bool,
@@ -81,7 +83,8 @@ pub struct KomorebiLayoutConfig {
pub display: Option<DisplayFormat>, pub display: Option<DisplayFormat>,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct KomorebiWorkspaceLayerConfig { pub struct KomorebiWorkspaceLayerConfig {
/// Enable the Komorebi Workspace Layer widget /// Enable the Komorebi Workspace Layer widget
pub enable: bool, pub enable: bool,
@@ -91,7 +94,8 @@ pub struct KomorebiWorkspaceLayerConfig {
pub show_when_tiling: Option<bool>, pub show_when_tiling: Option<bool>,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct KomorebiFocusedWindowConfig { pub struct KomorebiFocusedWindowConfig {
/// Enable the Komorebi Focused Window widget /// Enable the Komorebi Focused Window widget
pub enable: bool, pub enable: bool,
@@ -101,7 +105,8 @@ pub struct KomorebiFocusedWindowConfig {
pub display: Option<DisplayFormat>, pub display: Option<DisplayFormat>,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct KomorebiConfigurationSwitcherConfig { pub struct KomorebiConfigurationSwitcherConfig {
/// Enable the Komorebi Configurations widget /// Enable the Komorebi Configurations widget
pub enable: bool, pub enable: bool,
+2 -2
View File
@@ -14,7 +14,6 @@ use eframe::egui::StrokeKind;
use eframe::egui::Ui; use eframe::egui::Ui;
use eframe::egui::Vec2; use eframe::egui::Vec2;
use komorebi_client::SocketMessage; use komorebi_client::SocketMessage;
use schemars::JsonSchema;
use serde::de::Error; use serde::de::Error;
use serde::Deserialize; use serde::Deserialize;
use serde::Deserializer; use serde::Deserializer;
@@ -23,7 +22,8 @@ use serde_json::from_str;
use std::fmt::Display; use std::fmt::Display;
use std::fmt::Formatter; use std::fmt::Formatter;
#[derive(Copy, Clone, Debug, Serialize, JsonSchema, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum KomorebiLayout { pub enum KomorebiLayout {
Default(komorebi_client::DefaultLayout), Default(komorebi_client::DefaultLayout),
+2 -2
View File
@@ -30,7 +30,6 @@ use hotwatch::Hotwatch;
use image::RgbaImage; use image::RgbaImage;
use komorebi_client::SocketMessage; use komorebi_client::SocketMessage;
use komorebi_client::SubscribeOptions; use komorebi_client::SubscribeOptions;
use schemars::gen::SchemaSettings;
use std::collections::HashMap; use std::collections::HashMap;
use std::io::BufReader; use std::io::BufReader;
use std::io::Read; use std::io::Read;
@@ -125,8 +124,9 @@ fn main() -> color_eyre::Result<()> {
let opts: Opts = Opts::parse(); let opts: Opts = Opts::parse();
#[cfg(feature = "schemars")]
if opts.schema { if opts.schema {
let settings = SchemaSettings::default().with(|s| { let settings = schemars::gen::SchemaSettings::default().with(|s| {
s.option_nullable = false; s.option_nullable = false;
s.option_add_null_type = false; s.option_add_null_type = false;
s.inline_subschemas = true; s.inline_subschemas = true;
+2 -2
View File
@@ -10,13 +10,13 @@ use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use eframe::egui::Vec2; use eframe::egui::Vec2;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use windows::Media::Control::GlobalSystemMediaTransportControlsSessionManager; use windows::Media::Control::GlobalSystemMediaTransportControlsSessionManager;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct MediaConfig { pub struct MediaConfig {
/// Enable the Media widget /// Enable the Media widget
pub enable: bool, pub enable: bool,
+2 -2
View File
@@ -8,7 +8,6 @@ use eframe::egui::Context;
use eframe::egui::Label; use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::process::Command; use std::process::Command;
@@ -17,7 +16,8 @@ use std::time::Instant;
use sysinfo::RefreshKind; use sysinfo::RefreshKind;
use sysinfo::System; use sysinfo::System;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct MemoryConfig { pub struct MemoryConfig {
/// Enable the Memory widget /// Enable the Memory widget
pub enable: bool, pub enable: bool,
+2 -2
View File
@@ -9,7 +9,6 @@ use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use num_derive::FromPrimitive; use num_derive::FromPrimitive;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::fmt; use std::fmt;
@@ -18,7 +17,8 @@ use std::time::Duration;
use std::time::Instant; use std::time::Instant;
use sysinfo::Networks; use sysinfo::Networks;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct NetworkConfig { pub struct NetworkConfig {
/// Enable the Network widget /// Enable the Network widget
pub enable: bool, pub enable: bool,
+8 -5
View File
@@ -11,7 +11,6 @@ use eframe::egui::Margin;
use eframe::egui::Shadow; use eframe::egui::Shadow;
use eframe::egui::TextStyle; use eframe::egui::TextStyle;
use eframe::egui::Ui; use eframe::egui::Ui;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::sync::atomic::AtomicUsize; use std::sync::atomic::AtomicUsize;
@@ -20,7 +19,8 @@ use std::sync::Arc;
static SHOW_KOMOREBI_LAYOUT_OPTIONS: AtomicUsize = AtomicUsize::new(0); static SHOW_KOMOREBI_LAYOUT_OPTIONS: AtomicUsize = AtomicUsize::new(0);
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "kind")] #[serde(tag = "kind")]
pub enum Grouping { pub enum Grouping {
/// No grouping is applied /// No grouping is applied
@@ -339,7 +339,8 @@ impl RenderConfig {
} }
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct GroupingConfig { pub struct GroupingConfig {
/// Styles for the grouping /// Styles for the grouping
pub style: Option<GroupingStyle>, pub style: Option<GroupingStyle>,
@@ -349,7 +350,8 @@ pub struct GroupingConfig {
pub rounding: Option<RoundingConfig>, pub rounding: Option<RoundingConfig>,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum GroupingStyle { pub enum GroupingStyle {
#[serde(alias = "CtByte")] #[serde(alias = "CtByte")]
Default, Default,
@@ -369,7 +371,8 @@ pub enum GroupingStyle {
DefaultWithGlowB0O1S2, DefaultWithGlowB0O1S2,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum RoundingConfig { pub enum RoundingConfig {
/// All 4 corners are the same /// All 4 corners are the same
+2 -2
View File
@@ -8,7 +8,6 @@ use eframe::egui::Context;
use eframe::egui::Label; use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::process::Command; use std::process::Command;
@@ -16,7 +15,8 @@ use std::time::Duration;
use std::time::Instant; use std::time::Instant;
use sysinfo::Disks; use sysinfo::Disks;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct StorageConfig { pub struct StorageConfig {
/// Enable the Storage widget /// Enable the Storage widget
pub enable: bool, pub enable: bool,
+4 -3
View File
@@ -14,11 +14,11 @@ use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use eframe::egui::Vec2; use eframe::egui::Vec2;
use eframe::epaint::StrokeKind; use eframe::epaint::StrokeKind;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct TimeConfig { pub struct TimeConfig {
/// Enable the Time widget /// Enable the Time widget
pub enable: bool, pub enable: bool,
@@ -38,7 +38,8 @@ impl From<TimeConfig> for Time {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum TimeFormat { pub enum TimeFormat {
/// Twelve-hour format (with seconds) /// Twelve-hour format (with seconds)
TwelveHour, TwelveHour,
+2 -2
View File
@@ -8,14 +8,14 @@ use eframe::egui::Context;
use eframe::egui::Label; use eframe::egui::Label;
use eframe::egui::TextFormat; use eframe::egui::TextFormat;
use eframe::egui::Ui; use eframe::egui::Ui;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::process::Command; use std::process::Command;
use std::time::Duration; use std::time::Duration;
use std::time::Instant; use std::time::Instant;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct UpdateConfig { pub struct UpdateConfig {
/// Enable the Update widget /// Enable the Update widget
pub enable: bool, pub enable: bool,
+2 -2
View File
@@ -23,7 +23,6 @@ use crate::update::Update;
use crate::update::UpdateConfig; use crate::update::UpdateConfig;
use eframe::egui::Context; use eframe::egui::Context;
use eframe::egui::Ui; use eframe::egui::Ui;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@@ -31,7 +30,8 @@ pub trait BarWidget {
fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig); fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig);
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum WidgetConfig { pub enum WidgetConfig {
Battery(BatteryConfig), Battery(BatteryConfig),
Cpu(CpuConfig), Cpu(CpuConfig),
+3 -1
View File
@@ -29,7 +29,7 @@ os_info = "3.10"
parking_lot = "0.12" parking_lot = "0.12"
paste = { workspace = true } paste = { workspace = true }
regex = "1" regex = "1"
schemars = { workspace = true } schemars = { workspace = true, optional = true }
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
serde_yaml = { workspace = true } serde_yaml = { workspace = true }
@@ -57,4 +57,6 @@ shadow-rs = { workspace = true }
reqwest = { version = "0.12", features = ["blocking"] } reqwest = { version = "0.12", features = ["blocking"] }
[features] [features]
default = ["schemars"]
deadlock_detection = ["parking_lot/deadlock_detection"] deadlock_detection = ["parking_lot/deadlock_detection"]
schemars = ["dep:schemars"]
+2 -3
View File
@@ -1,7 +1,5 @@
use color_eyre::Result; use color_eyre::Result;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
@@ -13,7 +11,8 @@ use super::ANIMATION_DURATION_GLOBAL;
use super::ANIMATION_FPS; use super::ANIMATION_FPS;
use super::ANIMATION_MANAGER; use super::ANIMATION_MANAGER;
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct AnimationEngine; pub struct AnimationEngine;
impl AnimationEngine { impl AnimationEngine {
+3 -2
View File
@@ -18,11 +18,12 @@ pub mod prefix;
pub mod render_dispatcher; pub mod render_dispatcher;
pub use render_dispatcher::RenderDispatcher; pub use render_dispatcher::RenderDispatcher;
pub mod style; pub mod style;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum PerAnimationPrefixConfig<T> { pub enum PerAnimationPrefixConfig<T> {
Prefix(HashMap<AnimationPrefix, T>), Prefix(HashMap<AnimationPrefix, T>),
+3 -13
View File
@@ -1,24 +1,14 @@
use clap::ValueEnum; use clap::ValueEnum;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
use strum::EnumString; use strum::EnumString;
#[derive( #[derive(
Copy, Copy, Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Display, EnumString, ValueEnum,
Clone,
Debug,
Hash,
PartialEq,
Eq,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[strum(serialize_all = "snake_case")] #[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum AnimationPrefix { pub enum AnimationPrefix {
+2 -2
View File
@@ -19,7 +19,6 @@ use crossbeam_utils::atomic::AtomicCell;
use crossbeam_utils::atomic::AtomicConsume; use crossbeam_utils::atomic::AtomicConsume;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use parking_lot::Mutex; use parking_lot::Mutex;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
@@ -698,7 +697,8 @@ fn remove_border(
Ok(()) Ok(())
} }
#[derive(Debug, Copy, Clone, Display, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Copy, Clone, Display, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum ZOrder { pub enum ZOrder {
Top, Top,
NoTopMost, NoTopMost,
+11 -4
View File
@@ -1,14 +1,19 @@
use hex_color::HexColor; use hex_color::HexColor;
use komorebi_themes::Color32; use komorebi_themes::Color32;
#[cfg(feature = "schemars")]
use schemars::gen::SchemaGenerator; use schemars::gen::SchemaGenerator;
#[cfg(feature = "schemars")]
use schemars::schema::InstanceType; use schemars::schema::InstanceType;
#[cfg(feature = "schemars")]
use schemars::schema::Schema; use schemars::schema::Schema;
#[cfg(feature = "schemars")]
use schemars::schema::SchemaObject; use schemars::schema::SchemaObject;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
#[derive(Debug, Copy, Clone, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum Colour { pub enum Colour {
/// Colour represented as RGB /// Colour represented as RGB
@@ -54,7 +59,8 @@ impl From<Colour> for Color32 {
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
pub struct Hex(HexColor); pub struct Hex(HexColor);
impl JsonSchema for Hex { #[cfg(feature = "schemars")]
impl schemars::JsonSchema for Hex {
fn schema_name() -> String { fn schema_name() -> String {
String::from("Hex") String::from("Hex")
} }
@@ -78,7 +84,8 @@ impl From<Colour> for u32 {
} }
} }
#[derive(Debug, Copy, Clone, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Rgb { pub struct Rgb {
/// Red /// Red
pub r: u32, pub r: u32,
+2 -2
View File
@@ -2,14 +2,14 @@ use std::collections::VecDeque;
use getset::Getters; use getset::Getters;
use nanoid::nanoid; use nanoid::nanoid;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use crate::ring::Ring; use crate::ring::Ring;
use crate::window::Window; use crate::window::Window;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Getters, JsonSchema)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Getters)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Container { pub struct Container {
#[getset(get = "pub")] #[getset(get = "pub")]
id: String, id: String,
+3 -13
View File
@@ -1,22 +1,12 @@
use clap::ValueEnum; use clap::ValueEnum;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
use strum::EnumString; use strum::EnumString;
#[derive( #[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)]
Copy, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
Clone,
Debug,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
PartialEq,
)]
pub enum AnimationStyle { pub enum AnimationStyle {
Linear, Linear,
EaseInSine, EaseInSine,
+2 -13
View File
@@ -1,7 +1,6 @@
use std::num::NonZeroUsize; use std::num::NonZeroUsize;
use clap::ValueEnum; use clap::ValueEnum;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
@@ -603,18 +602,8 @@ impl Arrangement for CustomLayout {
} }
} }
#[derive( #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)]
Clone, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
Copy,
Debug,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
PartialEq,
)]
pub enum Axis { pub enum Axis {
Horizontal, Horizontal,
Vertical, Vertical,
+6 -4
View File
@@ -2,7 +2,6 @@ use crate::config_generation::ApplicationConfiguration;
use crate::config_generation::ApplicationOptions; use crate::config_generation::ApplicationOptions;
use crate::config_generation::MatchingRule; use crate::config_generation::MatchingRule;
use color_eyre::Result; use color_eyre::Result;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@@ -10,10 +9,12 @@ use std::ops::Deref;
use std::ops::DerefMut; use std::ops::DerefMut;
use std::path::PathBuf; use std::path::PathBuf;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ApplicationSpecificConfiguration(pub BTreeMap<String, AscApplicationRulesOrSchema>); pub struct ApplicationSpecificConfiguration(pub BTreeMap<String, AscApplicationRulesOrSchema>);
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum AscApplicationRulesOrSchema { pub enum AscApplicationRulesOrSchema {
AscApplicationRules(AscApplicationRules), AscApplicationRules(AscApplicationRules),
@@ -46,7 +47,8 @@ impl ApplicationSpecificConfiguration {
} }
/// Rules that determine how an application is handled /// Rules that determine how an application is handled
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct AscApplicationRules { pub struct AscApplicationRules {
/// Rules to ignore specific windows /// Rules to ignore specific windows
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
+16 -11
View File
@@ -1,6 +1,5 @@
use clap::ValueEnum; use clap::ValueEnum;
use color_eyre::Result; use color_eyre::Result;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
@@ -8,9 +7,8 @@ use strum::EnumString;
use super::ApplicationIdentifier; use super::ApplicationIdentifier;
#[derive( #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
#[strum(serialize_all = "snake_case")] #[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ApplicationOptions { pub enum ApplicationOptions {
@@ -52,14 +50,16 @@ impl ApplicationOptions {
} }
} }
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum MatchingRule { pub enum MatchingRule {
Simple(IdWithIdentifier), Simple(IdWithIdentifier),
Composite(Vec<IdWithIdentifier>), Composite(Vec<IdWithIdentifier>),
} }
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct WorkspaceMatchingRule { pub struct WorkspaceMatchingRule {
pub monitor_index: usize, pub monitor_index: usize,
pub workspace_index: usize, pub workspace_index: usize,
@@ -67,7 +67,8 @@ pub struct WorkspaceMatchingRule {
pub initial_only: bool, pub initial_only: bool,
} }
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct IdWithIdentifier { pub struct IdWithIdentifier {
pub kind: ApplicationIdentifier, pub kind: ApplicationIdentifier,
pub id: String, pub id: String,
@@ -75,7 +76,8 @@ pub struct IdWithIdentifier {
pub matching_strategy: Option<MatchingStrategy>, pub matching_strategy: Option<MatchingStrategy>,
} }
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display, JsonSchema)] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum MatchingStrategy { pub enum MatchingStrategy {
Legacy, Legacy,
Equals, Equals,
@@ -89,7 +91,8 @@ pub enum MatchingStrategy {
DoesNotContain, DoesNotContain,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct IdWithIdentifierAndComment { pub struct IdWithIdentifierAndComment {
pub kind: ApplicationIdentifier, pub kind: ApplicationIdentifier,
pub id: String, pub id: String,
@@ -109,7 +112,8 @@ impl From<IdWithIdentifierAndComment> for IdWithIdentifier {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ApplicationConfiguration { pub struct ApplicationConfiguration {
pub name: String, pub name: String,
pub identifier: IdWithIdentifier, pub identifier: IdWithIdentifier,
@@ -133,7 +137,8 @@ impl ApplicationConfiguration {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ApplicationConfigurationGenerator; pub struct ApplicationConfigurationGenerator;
impl ApplicationConfigurationGenerator { impl ApplicationConfigurationGenerator {
+10 -6
View File
@@ -8,13 +8,13 @@ use std::path::Path;
use color_eyre::eyre::anyhow; use color_eyre::eyre::anyhow;
use color_eyre::eyre::bail; use color_eyre::eyre::bail;
use color_eyre::Result; use color_eyre::Result;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use super::Rect; use super::Rect;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct CustomLayout(Vec<Column>); pub struct CustomLayout(Vec<Column>);
impl Deref for CustomLayout { impl Deref for CustomLayout {
@@ -250,7 +250,8 @@ impl CustomLayout {
} }
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "column", content = "configuration")] #[serde(tag = "column", content = "configuration")]
pub enum Column { pub enum Column {
Primary(Option<ColumnWidth>), Primary(Option<ColumnWidth>),
@@ -258,18 +259,21 @@ pub enum Column {
Tertiary(ColumnSplit), Tertiary(ColumnSplit),
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum ColumnWidth { pub enum ColumnWidth {
WidthPercentage(f32), WidthPercentage(f32),
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum ColumnSplit { pub enum ColumnSplit {
Horizontal, Horizontal,
Vertical, Vertical,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum ColumnSplitWithCapacity { pub enum ColumnSplitWithCapacity {
Horizontal(usize), Horizontal(usize),
Vertical(usize), Vertical(usize),
+2 -4
View File
@@ -1,15 +1,13 @@
use std::num::NonZeroUsize; use std::num::NonZeroUsize;
use clap::ValueEnum; use clap::ValueEnum;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
use strum::EnumString; use strum::EnumString;
#[derive( #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
pub enum CycleDirection { pub enum CycleDirection {
Previous, Previous,
Next, Next,
+2 -12
View File
@@ -1,5 +1,4 @@
use clap::ValueEnum; use clap::ValueEnum;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
@@ -10,18 +9,9 @@ use super::Rect;
use super::Sizing; use super::Sizing;
#[derive( #[derive(
Clone, Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq, Display, EnumString, ValueEnum,
Copy,
Debug,
Serialize,
Deserialize,
Eq,
PartialEq,
Display,
EnumString,
ValueEnum,
JsonSchema,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum DefaultLayout { pub enum DefaultLayout {
BSP, BSP,
Columns, Columns,
+2 -2
View File
@@ -1,4 +1,3 @@
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@@ -7,7 +6,8 @@ use super::CustomLayout;
use super::DefaultLayout; use super::DefaultLayout;
use super::Direction; use super::Direction;
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum Layout { pub enum Layout {
Default(DefaultLayout), Default(DefaultLayout),
Custom(CustomLayout), Custom(CustomLayout),
+34 -132
View File
@@ -8,7 +8,6 @@ use std::str::FromStr;
use clap::ValueEnum; use clap::ValueEnum;
use color_eyre::eyre::anyhow; use color_eyre::eyre::anyhow;
use color_eyre::Result; use color_eyre::Result;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
@@ -45,7 +44,8 @@ pub mod operation_direction;
pub mod pathext; pub mod pathext;
pub mod rect; pub mod rect;
#[derive(Clone, Debug, Serialize, Deserialize, Display, JsonSchema)] #[derive(Clone, Debug, Serialize, Deserialize, Display)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "type", content = "content")] #[serde(tag = "type", content = "content")]
pub enum SocketMessage { pub enum SocketMessage {
// Window / Container Commands // Window / Container Commands
@@ -241,24 +241,23 @@ impl FromStr for SocketMessage {
} }
} }
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize, JsonSchema)] #[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct SubscribeOptions { pub struct SubscribeOptions {
/// Only emit notifications when the window manager state has changed /// Only emit notifications when the window manager state has changed
pub filter_state_changes: bool, pub filter_state_changes: bool,
} }
#[derive( #[derive(Debug, Copy, Clone, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum)]
Debug, Copy, Clone, Eq, PartialEq, Display, Serialize, Deserialize, JsonSchema, ValueEnum, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
pub enum StackbarMode { pub enum StackbarMode {
Always, Always,
Never, Never,
OnStack, OnStack,
} }
#[derive( #[derive(Debug, Copy, Default, Clone, Eq, PartialEq, Display, Serialize, Deserialize)]
Debug, Copy, Default, Clone, Eq, PartialEq, Display, Serialize, Deserialize, JsonSchema, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
pub enum StackbarLabel { pub enum StackbarLabel {
#[default] #[default]
Process, Process,
@@ -266,18 +265,9 @@ pub enum StackbarLabel {
} }
#[derive( #[derive(
Default, Default, Copy, Clone, Debug, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum,
Copy,
Clone,
Debug,
Eq,
PartialEq,
Display,
Serialize,
Deserialize,
JsonSchema,
ValueEnum,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum BorderStyle { pub enum BorderStyle {
#[default] #[default]
/// Use the system border style /// Use the system border style
@@ -289,18 +279,9 @@ pub enum BorderStyle {
} }
#[derive( #[derive(
Default, Default, Copy, Clone, Debug, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum,
Copy,
Clone,
Debug,
Eq,
PartialEq,
Display,
Serialize,
Deserialize,
JsonSchema,
ValueEnum,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum BorderImplementation { pub enum BorderImplementation {
#[default] #[default]
/// Use the adjustable komorebi border implementation /// Use the adjustable komorebi border implementation
@@ -310,19 +291,9 @@ pub enum BorderImplementation {
} }
#[derive( #[derive(
Copy, Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, Eq, Hash,
Clone,
Debug,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
PartialEq,
Eq,
Hash,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum WindowKind { pub enum WindowKind {
Single, Single,
Stack, Stack,
@@ -331,9 +302,8 @@ pub enum WindowKind {
Floating, Floating,
} }
#[derive( #[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
pub enum StateQuery { pub enum StateQuery {
FocusedMonitorIndex, FocusedMonitorIndex,
FocusedWorkspaceIndex, FocusedWorkspaceIndex,
@@ -343,18 +313,9 @@ pub enum StateQuery {
} }
#[derive( #[derive(
Copy, Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum,
Clone,
Debug,
Eq,
PartialEq,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum ApplicationIdentifier { pub enum ApplicationIdentifier {
#[serde(alias = "exe")] #[serde(alias = "exe")]
Exe, Exe,
@@ -366,18 +327,8 @@ pub enum ApplicationIdentifier {
Path, Path,
} }
#[derive( #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Copy, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
Clone,
Debug,
PartialEq,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
)]
pub enum FocusFollowsMouseImplementation { pub enum FocusFollowsMouseImplementation {
/// A custom FFM implementation (slightly more CPU-intensive) /// A custom FFM implementation (slightly more CPU-intensive)
Komorebi, Komorebi,
@@ -385,7 +336,8 @@ pub enum FocusFollowsMouseImplementation {
Windows, Windows,
} }
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct WindowManagementBehaviour { pub struct WindowManagementBehaviour {
/// The current WindowContainerBehaviour to be used /// The current WindowContainerBehaviour to be used
pub current_behaviour: WindowContainerBehaviour, pub current_behaviour: WindowContainerBehaviour,
@@ -396,18 +348,9 @@ pub struct WindowManagementBehaviour {
} }
#[derive( #[derive(
Clone, Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq,
Copy,
Debug,
Default,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
PartialEq,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum WindowContainerBehaviour { pub enum WindowContainerBehaviour {
/// Create a new container for each new window /// Create a new container for each new window
#[default] #[default]
@@ -416,18 +359,8 @@ pub enum WindowContainerBehaviour {
Append, Append,
} }
#[derive( #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Clone, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
Copy,
Debug,
PartialEq,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
)]
pub enum MoveBehaviour { pub enum MoveBehaviour {
/// Swap the window container with the window container at the edge of the adjacent monitor /// Swap the window container with the window container at the edge of the adjacent monitor
Swap, Swap,
@@ -437,18 +370,8 @@ pub enum MoveBehaviour {
NoOp, NoOp,
} }
#[derive( #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)]
Clone, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
Copy,
Debug,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
PartialEq,
)]
pub enum CrossBoundaryBehaviour { pub enum CrossBoundaryBehaviour {
/// Attempt to perform actions across a workspace boundary /// Attempt to perform actions across a workspace boundary
Workspace, Workspace,
@@ -456,18 +379,8 @@ pub enum CrossBoundaryBehaviour {
Monitor, Monitor,
} }
#[derive( #[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)]
Copy, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
Clone,
Debug,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
PartialEq,
)]
pub enum HidingBehaviour { pub enum HidingBehaviour {
/// Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps) /// Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps)
Hide, Hide,
@@ -477,18 +390,8 @@ pub enum HidingBehaviour {
Cloak, Cloak,
} }
#[derive( #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Clone, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
Copy,
Debug,
PartialEq,
Serialize,
Deserialize,
Display,
EnumString,
ValueEnum,
JsonSchema,
)]
pub enum OperationBehaviour { pub enum OperationBehaviour {
/// Process komorebic commands on temporarily unmanaged/floated windows /// Process komorebic commands on temporarily unmanaged/floated windows
Op, Op,
@@ -496,9 +399,8 @@ pub enum OperationBehaviour {
NoOp, NoOp,
} }
#[derive( #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
pub enum Sizing { pub enum Sizing {
Increase, Increase,
Decrease, Decrease,
+2 -4
View File
@@ -1,7 +1,6 @@
use std::num::NonZeroUsize; use std::num::NonZeroUsize;
use clap::ValueEnum; use clap::ValueEnum;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
@@ -10,9 +9,8 @@ use strum::EnumString;
use super::direction::Direction; use super::direction::Direction;
use super::Axis; use super::Axis;
#[derive( #[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)]
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
pub enum OperationDirection { pub enum OperationDirection {
Left, Left,
Right, Right,
+2 -2
View File
@@ -1,9 +1,9 @@
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use windows::Win32::Foundation::RECT; use windows::Win32::Foundation::RECT;
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, JsonSchema)] #[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Rect { pub struct Rect {
/// The left point in a Win32 Rect /// The left point in a Win32 Rect
pub left: i32, pub left: i32,
+4 -3
View File
@@ -66,7 +66,6 @@ use color_eyre::Result;
use os_info::Version; use os_info::Version;
use parking_lot::Mutex; use parking_lot::Mutex;
use regex::Regex; use regex::Regex;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use uds_windows::UnixStream; use uds_windows::UnixStream;
@@ -280,7 +279,8 @@ pub fn current_virtual_desktop() -> Option<Vec<u8>> {
current current
} }
#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)] #[serde(untagged)]
pub enum NotificationEvent { pub enum NotificationEvent {
WindowManager(WindowManagerEvent), WindowManager(WindowManagerEvent),
@@ -288,7 +288,8 @@ pub enum NotificationEvent {
Monitor(MonitorNotification), Monitor(MonitorNotification),
} }
#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Notification { pub struct Notification {
pub event: NotificationEvent, pub event: NotificationEvent,
pub state: State, pub state: State,
+2 -11
View File
@@ -9,7 +9,6 @@ use getset::CopyGetters;
use getset::Getters; use getset::Getters;
use getset::MutGetters; use getset::MutGetters;
use getset::Setters; use getset::Setters;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@@ -26,17 +25,9 @@ use crate::DEFAULT_CONTAINER_PADDING;
use crate::DEFAULT_WORKSPACE_PADDING; use crate::DEFAULT_WORKSPACE_PADDING;
#[derive( #[derive(
Debug, Debug, Clone, Serialize, Deserialize, Getters, CopyGetters, MutGetters, Setters, PartialEq,
Clone,
Serialize,
Deserialize,
Getters,
CopyGetters,
MutGetters,
Setters,
JsonSchema,
PartialEq,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Monitor { pub struct Monitor {
#[getset(get_copy = "pub", set = "pub")] #[getset(get_copy = "pub", set = "pub")]
pub id: isize, pub id: isize,
+2 -2
View File
@@ -17,7 +17,6 @@ use crossbeam_channel::Receiver;
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossbeam_utils::atomic::AtomicConsume; use crossbeam_utils::atomic::AtomicConsume;
use parking_lot::Mutex; use parking_lot::Mutex;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::collections::HashMap; use std::collections::HashMap;
@@ -28,7 +27,8 @@ use std::sync::OnceLock;
pub mod hidden; pub mod hidden;
#[derive(Debug, Copy, Clone, Serialize, Deserialize, JsonSchema)] #[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "type", content = "content")] #[serde(tag = "type", content = "content")]
pub enum MonitorNotification { pub enum MonitorNotification {
ResolutionScalingChanged, ResolutionScalingChanged,
+37 -27
View File
@@ -1,3 +1,8 @@
use color_eyre::eyre::anyhow;
use color_eyre::Result;
use miow::pipe::connect;
use net2::TcpStreamExt;
use parking_lot::Mutex;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::fs::OpenOptions; use std::fs::OpenOptions;
@@ -11,20 +16,11 @@ use std::str::FromStr;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use color_eyre::eyre::anyhow;
use color_eyre::Result;
use miow::pipe::connect;
use net2::TcpStreamExt;
use parking_lot::Mutex;
use schemars::gen::SchemaSettings;
use schemars::schema_for;
use uds_windows::UnixStream; use uds_windows::UnixStream;
use crate::animation::ANIMATION_DURATION_PER_ANIMATION; use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION; use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
use crate::animation::ANIMATION_STYLE_PER_ANIMATION; use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
use crate::core::config_generation::ApplicationConfiguration;
use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::IdWithIdentifier;
use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingRule;
use crate::core::config_generation::MatchingStrategy; use crate::core::config_generation::MatchingStrategy;
@@ -1828,35 +1824,49 @@ impl WindowManager {
*STACKBAR_FONT_FAMILY.lock() = font_family.clone(); *STACKBAR_FONT_FAMILY.lock() = font_family.clone();
} }
SocketMessage::ApplicationSpecificConfigurationSchema => { SocketMessage::ApplicationSpecificConfigurationSchema => {
let asc = schema_for!(Vec<ApplicationConfiguration>); #[cfg(feature = "schemars")]
let schema = serde_json::to_string_pretty(&asc)?; {
let asc = schemars::schema_for!(
Vec<crate::core::config_generation::ApplicationConfiguration>
);
let schema = serde_json::to_string_pretty(&asc)?;
reply.write_all(schema.as_bytes())?; reply.write_all(schema.as_bytes())?;
}
} }
SocketMessage::NotificationSchema => { SocketMessage::NotificationSchema => {
let notification = schema_for!(Notification); #[cfg(feature = "schemars")]
let schema = serde_json::to_string_pretty(&notification)?; {
let notification = schemars::schema_for!(Notification);
let schema = serde_json::to_string_pretty(&notification)?;
reply.write_all(schema.as_bytes())?; reply.write_all(schema.as_bytes())?;
}
} }
SocketMessage::SocketSchema => { SocketMessage::SocketSchema => {
let socket_message = schema_for!(SocketMessage); #[cfg(feature = "schemars")]
let schema = serde_json::to_string_pretty(&socket_message)?; {
let socket_message = schemars::schema_for!(SocketMessage);
let schema = serde_json::to_string_pretty(&socket_message)?;
reply.write_all(schema.as_bytes())?; reply.write_all(schema.as_bytes())?;
}
} }
SocketMessage::StaticConfigSchema => { SocketMessage::StaticConfigSchema => {
let settings = SchemaSettings::default().with(|s| { #[cfg(feature = "schemars")]
s.option_nullable = false; {
s.option_add_null_type = false; let settings = schemars::gen::SchemaSettings::default().with(|s| {
s.inline_subschemas = true; s.option_nullable = false;
}); s.option_add_null_type = false;
s.inline_subschemas = true;
});
let gen = settings.into_generator(); let gen = settings.into_generator();
let socket_message = gen.into_root_schema_for::<StaticConfig>(); let socket_message = gen.into_root_schema_for::<StaticConfig>();
let schema = serde_json::to_string_pretty(&socket_message)?; let schema = serde_json::to_string_pretty(&socket_message)?;
reply.write_all(schema.as_bytes())?; reply.write_all(schema.as_bytes())?;
}
} }
SocketMessage::GenerateStaticConfig => { SocketMessage::GenerateStaticConfig => {
let config = serde_json::to_string_pretty(&StaticConfig::from(&*self))?; let config = serde_json::to_string_pretty(&StaticConfig::from(&*self))?;
+2 -2
View File
@@ -1,10 +1,10 @@
use std::collections::VecDeque; use std::collections::VecDeque;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Ring<T> { pub struct Ring<T> {
elements: VecDeque<T>, elements: VecDeque<T>,
focused: usize, focused: usize,
+37 -31
View File
@@ -7,14 +7,35 @@ use crate::animation::ANIMATION_FPS;
use crate::animation::ANIMATION_STYLE_GLOBAL; use crate::animation::ANIMATION_STYLE_GLOBAL;
use crate::animation::ANIMATION_STYLE_PER_ANIMATION; use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
use crate::animation::DEFAULT_ANIMATION_FPS; use crate::animation::DEFAULT_ANIMATION_FPS;
use crate::asc::ApplicationSpecificConfiguration;
use crate::asc::AscApplicationRulesOrSchema;
use crate::border_manager; use crate::border_manager;
use crate::border_manager::ZOrder; use crate::border_manager::ZOrder;
use crate::border_manager::IMPLEMENTATION; use crate::border_manager::IMPLEMENTATION;
use crate::border_manager::STYLE; use crate::border_manager::STYLE;
use crate::colour::Colour; use crate::colour::Colour;
use crate::config_generation::WorkspaceMatchingRule;
use crate::core::config_generation::ApplicationConfiguration;
use crate::core::config_generation::ApplicationConfigurationGenerator;
use crate::core::config_generation::ApplicationOptions;
use crate::core::config_generation::MatchingRule;
use crate::core::config_generation::MatchingStrategy;
use crate::core::resolve_home_path;
use crate::core::AnimationStyle;
use crate::core::BorderImplementation; use crate::core::BorderImplementation;
use crate::core::BorderStyle;
use crate::core::DefaultLayout;
use crate::core::FocusFollowsMouseImplementation;
use crate::core::HidingBehaviour;
use crate::core::Layout;
use crate::core::MoveBehaviour;
use crate::core::OperationBehaviour;
use crate::core::Rect;
use crate::core::SocketMessage;
use crate::core::StackbarLabel; use crate::core::StackbarLabel;
use crate::core::StackbarMode; use crate::core::StackbarMode;
use crate::core::WindowContainerBehaviour;
use crate::core::WindowManagementBehaviour;
use crate::current_virtual_desktop; use crate::current_virtual_desktop;
use crate::monitor; use crate::monitor;
use crate::monitor::Monitor; use crate::monitor::Monitor;
@@ -61,35 +82,12 @@ use crate::TRANSPARENCY_BLACKLIST;
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS; use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
use crate::WINDOWS_11; use crate::WINDOWS_11;
use crate::WORKSPACE_MATCHING_RULES; use crate::WORKSPACE_MATCHING_RULES;
use crate::asc::ApplicationSpecificConfiguration;
use crate::asc::AscApplicationRulesOrSchema;
use crate::config_generation::WorkspaceMatchingRule;
use crate::core::config_generation::ApplicationConfiguration;
use crate::core::config_generation::ApplicationConfigurationGenerator;
use crate::core::config_generation::ApplicationOptions;
use crate::core::config_generation::MatchingRule;
use crate::core::config_generation::MatchingStrategy;
use crate::core::resolve_home_path;
use crate::core::AnimationStyle;
use crate::core::BorderStyle;
use crate::core::DefaultLayout;
use crate::core::FocusFollowsMouseImplementation;
use crate::core::HidingBehaviour;
use crate::core::Layout;
use crate::core::MoveBehaviour;
use crate::core::OperationBehaviour;
use crate::core::Rect;
use crate::core::SocketMessage;
use crate::core::WindowContainerBehaviour;
use crate::core::WindowManagementBehaviour;
use color_eyre::Result; use color_eyre::Result;
use crossbeam_channel::Receiver; use crossbeam_channel::Receiver;
use hotwatch::EventKind; use hotwatch::EventKind;
use hotwatch::Hotwatch; use hotwatch::Hotwatch;
use parking_lot::Mutex; use parking_lot::Mutex;
use regex::Regex; use regex::Regex;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::collections::HashMap; use std::collections::HashMap;
@@ -102,7 +100,8 @@ use std::sync::Arc;
use uds_windows::UnixListener; use uds_windows::UnixListener;
use uds_windows::UnixStream; use uds_windows::UnixStream;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct BorderColours { pub struct BorderColours {
/// Border colour when the container contains a single window /// Border colour when the container contains a single window
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@@ -121,7 +120,8 @@ pub struct BorderColours {
pub unfocused: Option<Colour>, pub unfocused: Option<Colour>,
} }
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct WorkspaceConfig { pub struct WorkspaceConfig {
/// Name /// Name
pub name: String, pub name: String,
@@ -243,7 +243,8 @@ impl From<&Workspace> for WorkspaceConfig {
} }
} }
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct MonitorConfig { pub struct MonitorConfig {
/// Workspace configurations /// Workspace configurations
pub workspaces: Vec<WorkspaceConfig>, pub workspaces: Vec<WorkspaceConfig>,
@@ -301,7 +302,8 @@ impl From<&Monitor> for MonitorConfig {
} }
} }
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
/// The `komorebi.json` static configuration file reference for `v0.1.35` /// The `komorebi.json` static configuration file reference for `v0.1.35`
pub struct StaticConfig { pub struct StaticConfig {
/// DEPRECATED from v0.1.22: no longer required /// DEPRECATED from v0.1.22: no longer required
@@ -449,7 +451,8 @@ pub struct StaticConfig {
pub floating_window_aspect_ratio: Option<AspectRatio>, pub floating_window_aspect_ratio: Option<AspectRatio>,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct AnimationsConfig { pub struct AnimationsConfig {
/// Enable or disable animations (default: false) /// Enable or disable animations (default: false)
pub enabled: PerAnimationPrefixConfig<bool>, pub enabled: PerAnimationPrefixConfig<bool>,
@@ -464,7 +467,8 @@ pub struct AnimationsConfig {
pub fps: Option<u64>, pub fps: Option<u64>,
} }
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "palette")] #[serde(tag = "palette")]
pub enum KomorebiTheme { pub enum KomorebiTheme {
/// A theme from catppuccin-egui /// A theme from catppuccin-egui
@@ -614,7 +618,8 @@ impl StaticConfig {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct TabsConfig { pub struct TabsConfig {
/// Width of a stackbar tab /// Width of a stackbar tab
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@@ -636,7 +641,8 @@ pub struct TabsConfig {
pub font_size: Option<i32>, pub font_size: Option<i32>,
} }
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct StackbarConfig { pub struct StackbarConfig {
/// Stackbar height /// Stackbar height
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
+37 -41
View File
@@ -11,13 +11,42 @@ use crate::animation::ANIMATION_MANAGER;
use crate::animation::ANIMATION_STYLE_GLOBAL; use crate::animation::ANIMATION_STYLE_GLOBAL;
use crate::animation::ANIMATION_STYLE_PER_ANIMATION; use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
use crate::com::SetCloak; use crate::com::SetCloak;
use crate::core::config_generation::IdWithIdentifier;
use crate::core::config_generation::MatchingRule;
use crate::core::config_generation::MatchingStrategy;
use crate::core::ApplicationIdentifier;
use crate::core::HidingBehaviour;
use crate::core::Rect;
use crate::focus_manager; use crate::focus_manager;
use crate::stackbar_manager; use crate::stackbar_manager;
use crate::styles::ExtendedWindowStyle;
use crate::styles::WindowStyle;
use crate::transparency_manager;
use crate::window_manager_event::WindowManagerEvent;
use crate::windows_api; use crate::windows_api;
use crate::windows_api::WindowsApi;
use crate::AnimationStyle; use crate::AnimationStyle;
use crate::FLOATING_APPLICATIONS;
use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO; use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO;
use crate::HIDDEN_HWNDS;
use crate::HIDING_BEHAVIOUR;
use crate::IGNORE_IDENTIFIERS;
use crate::LAYERED_WHITELIST;
use crate::MANAGE_IDENTIFIERS;
use crate::NO_TITLEBAR;
use crate::PERMAIGNORE_CLASSES;
use crate::REGEX_IDENTIFIERS;
use crate::SLOW_APPLICATION_COMPENSATION_TIME; use crate::SLOW_APPLICATION_COMPENSATION_TIME;
use crate::SLOW_APPLICATION_IDENTIFIERS; use crate::SLOW_APPLICATION_IDENTIFIERS;
use crate::WSL2_UI_PROCESSES;
use color_eyre::eyre;
use color_eyre::Result;
use crossbeam_utils::atomic::AtomicConsume;
use regex::Regex;
use serde::ser::SerializeStruct;
use serde::Deserialize;
use serde::Serialize;
use serde::Serializer;
use std::collections::HashMap; use std::collections::HashMap;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::fmt::Display; use std::fmt::Display;
@@ -27,47 +56,15 @@ use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use crate::core::config_generation::IdWithIdentifier;
use crate::core::config_generation::MatchingRule;
use crate::core::config_generation::MatchingStrategy;
use color_eyre::eyre;
use color_eyre::Result;
use crossbeam_utils::atomic::AtomicConsume;
use regex::Regex;
use schemars::JsonSchema;
use serde::ser::SerializeStruct;
use serde::Deserialize;
use serde::Serialize;
use serde::Serializer;
use strum::Display; use strum::Display;
use strum::EnumString; use strum::EnumString;
use windows::Win32::Foundation::HWND; use windows::Win32::Foundation::HWND;
use crate::core::ApplicationIdentifier;
use crate::core::HidingBehaviour;
use crate::core::Rect;
use crate::styles::ExtendedWindowStyle;
use crate::styles::WindowStyle;
use crate::transparency_manager;
use crate::window_manager_event::WindowManagerEvent;
use crate::windows_api::WindowsApi;
use crate::FLOATING_APPLICATIONS;
use crate::HIDDEN_HWNDS;
use crate::HIDING_BEHAVIOUR;
use crate::IGNORE_IDENTIFIERS;
use crate::LAYERED_WHITELIST;
use crate::MANAGE_IDENTIFIERS;
use crate::NO_TITLEBAR;
use crate::PERMAIGNORE_CLASSES;
use crate::REGEX_IDENTIFIERS;
use crate::WSL2_UI_PROCESSES;
pub static MINIMUM_WIDTH: AtomicI32 = AtomicI32::new(0); pub static MINIMUM_WIDTH: AtomicI32 = AtomicI32::new(0);
pub static MINIMUM_HEIGHT: AtomicI32 = AtomicI32::new(0); pub static MINIMUM_HEIGHT: AtomicI32 = AtomicI32::new(0);
#[derive(Debug, Default, Clone, Copy, Deserialize, JsonSchema, PartialEq)] #[derive(Debug, Default, Clone, Copy, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Window { pub struct Window {
pub hwnd: isize, pub hwnd: isize,
} }
@@ -87,7 +84,8 @@ impl From<HWND> for Window {
} }
#[allow(clippy::module_name_repetitions)] #[allow(clippy::module_name_repetitions)]
#[derive(Debug, Clone, Serialize, JsonSchema)] #[derive(Debug, Clone, Serialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct WindowDetails { pub struct WindowDetails {
pub title: String, pub title: String,
pub exe: String, pub exe: String,
@@ -299,9 +297,8 @@ impl RenderDispatcher for TransparencyRenderDispatcher {
} }
} }
#[derive( #[derive(Copy, Clone, Debug, Display, EnumString, Serialize, Deserialize, PartialEq)]
Copy, Clone, Debug, Display, EnumString, Serialize, Deserialize, JsonSchema, PartialEq, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
#[serde(untagged)] #[serde(untagged)]
pub enum AspectRatio { pub enum AspectRatio {
/// A predefined aspect ratio /// A predefined aspect ratio
@@ -316,9 +313,8 @@ impl Default for AspectRatio {
} }
} }
#[derive( #[derive(Copy, Clone, Debug, Default, Display, EnumString, Serialize, Deserialize, PartialEq)]
Copy, Clone, Debug, Default, Display, EnumString, Serialize, Deserialize, JsonSchema, PartialEq, #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
)]
pub enum PredefinedAspectRatio { pub enum PredefinedAspectRatio {
/// 21:9 /// 21:9
Ultrawide, Ultrawide,
+4 -3
View File
@@ -19,7 +19,6 @@ use hotwatch::notify::ErrorKind as NotifyErrorKind;
use hotwatch::EventKind; use hotwatch::EventKind;
use hotwatch::Hotwatch; use hotwatch::Hotwatch;
use parking_lot::Mutex; use parking_lot::Mutex;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use uds_windows::UnixListener; use uds_windows::UnixListener;
@@ -126,7 +125,8 @@ pub struct WindowManager {
} }
#[allow(clippy::struct_excessive_bools)] #[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct State { pub struct State {
pub monitors: Ring<Monitor>, pub monitors: Ring<Monitor>,
pub monitor_usr_idx_map: HashMap<usize, usize>, pub monitor_usr_idx_map: HashMap<usize, usize>,
@@ -191,7 +191,8 @@ impl State {
} }
#[allow(clippy::struct_excessive_bools)] #[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct GlobalState { pub struct GlobalState {
pub border_enabled: bool, pub border_enabled: bool,
pub border_colours: BorderColours, pub border_colours: BorderColours,
+2 -2
View File
@@ -1,7 +1,6 @@
use std::fmt::Display; use std::fmt::Display;
use std::fmt::Formatter; use std::fmt::Formatter;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@@ -12,7 +11,8 @@ use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
use crate::OBJECT_NAME_CHANGE_TITLE_IGNORE_LIST; use crate::OBJECT_NAME_CHANGE_TITLE_IGNORE_LIST;
use crate::REGEX_IDENTIFIERS; use crate::REGEX_IDENTIFIERS;
#[derive(Debug, Copy, Clone, Serialize, Deserialize, JsonSchema)] #[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "type", content = "content")] #[serde(tag = "type", content = "content")]
pub enum WindowManagerEvent { pub enum WindowManagerEvent {
Destroy(WinEvent, Window), Destroy(WinEvent, Window),
+2 -2
View File
@@ -1,6 +1,5 @@
#![allow(clippy::use_self)] #![allow(clippy::use_self)]
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use strum::Display; use strum::Display;
@@ -89,7 +88,8 @@ use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_EVENTID_START;
use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_PROPID_END; use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_PROPID_END;
use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_PROPID_START; use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_PROPID_START;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, Display, JsonSchema)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, Display)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(u32)] #[repr(u32)]
#[allow(dead_code)] #[allow(dead_code)]
pub enum WinEvent { pub enum WinEvent {
+5 -13
View File
@@ -10,7 +10,6 @@ use getset::CopyGetters;
use getset::Getters; use getset::Getters;
use getset::MutGetters; use getset::MutGetters;
use getset::Setters; use getset::Setters;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@@ -43,17 +42,9 @@ use crate::REMOVE_TITLEBARS;
#[allow(clippy::struct_field_names)] #[allow(clippy::struct_field_names)]
#[derive( #[derive(
Debug, Debug, Clone, Serialize, Deserialize, Getters, CopyGetters, MutGetters, Setters, PartialEq,
Clone,
Serialize,
Deserialize,
Getters,
CopyGetters,
MutGetters,
Setters,
JsonSchema,
PartialEq,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Workspace { pub struct Workspace {
#[getset(get = "pub", set = "pub")] #[getset(get = "pub", set = "pub")]
pub name: Option<String>, pub name: Option<String>,
@@ -103,7 +94,8 @@ pub struct Workspace {
pub workspace_config: Option<WorkspaceConfig>, pub workspace_config: Option<WorkspaceConfig>,
} }
#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum WorkspaceLayer { pub enum WorkspaceLayer {
#[default] #[default]
Tiling, Tiling,
@@ -169,9 +161,9 @@ pub enum WorkspaceWindowLocation {
CopyGetters, CopyGetters,
MutGetters, MutGetters,
Setters, Setters,
JsonSchema,
PartialEq, PartialEq,
)] )]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
/// Settings setup either by the parent monitor or by the `WindowManager` /// Settings setup either by the parent monitor or by the `WindowManager`
pub struct WorkspaceGlobals { pub struct WorkspaceGlobals {
pub container_padding: Option<i32>, pub container_padding: Option<i32>,
+5 -1
View File
@@ -21,7 +21,7 @@ miette = { version = "7", features = ["fancy"] }
paste = { workspace = true } paste = { workspace = true }
powershell_script = "1.0" powershell_script = "1.0"
reqwest = { version = "0.12", features = ["blocking"] } reqwest = { version = "0.12", features = ["blocking"] }
schemars = { workspace = true } schemars = { workspace = true, optional = true }
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
shadow-rs = { workspace = true } shadow-rs = { workspace = true }
@@ -34,5 +34,9 @@ windows = { workspace = true }
reqwest = { version = "0.12", features = ["blocking"] } reqwest = { version = "0.12", features = ["blocking"] }
shadow-rs = { workspace = true } shadow-rs = { workspace = true }
[features]
default = ["schemars"]
schemars = ["dep:schemars"]
[lints.rust] [lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(FALSE)'] } unexpected_cfgs = { level = "warn", check-cfg = ['cfg(FALSE)'] }
+30 -21
View File
@@ -26,15 +26,12 @@ use komorebi_client::resolve_home_path;
use komorebi_client::send_message; use komorebi_client::send_message;
use komorebi_client::send_query; use komorebi_client::send_query;
use komorebi_client::ApplicationSpecificConfiguration; use komorebi_client::ApplicationSpecificConfiguration;
use komorebi_client::Notification;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use miette::NamedSource; use miette::NamedSource;
use miette::Report; use miette::Report;
use miette::SourceOffset; use miette::SourceOffset;
use miette::SourceSpan; use miette::SourceSpan;
use paste::paste; use paste::paste;
use schemars::gen::SchemaSettings;
use schemars::schema_for;
use serde::Deserialize; use serde::Deserialize;
use sysinfo::ProcessesToUpdate; use sysinfo::ProcessesToUpdate;
use which::which; use which::which;
@@ -2973,31 +2970,43 @@ if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) {
); );
} }
SubCommand::ApplicationSpecificConfigurationSchema => { SubCommand::ApplicationSpecificConfigurationSchema => {
let asc = schema_for!(ApplicationSpecificConfiguration); #[cfg(feature = "schemars")]
let schema = serde_json::to_string_pretty(&asc)?; {
println!("{schema}"); let asc = schemars::schema_for!(ApplicationSpecificConfiguration);
let schema = serde_json::to_string_pretty(&asc)?;
println!("{schema}");
}
} }
SubCommand::NotificationSchema => { SubCommand::NotificationSchema => {
let notification = schema_for!(Notification); #[cfg(feature = "schemars")]
let schema = serde_json::to_string_pretty(&notification)?; {
println!("{schema}"); let notification = schemars::schema_for!(komorebi_client::Notification);
let schema = serde_json::to_string_pretty(&notification)?;
println!("{schema}");
}
} }
SubCommand::SocketSchema => { SubCommand::SocketSchema => {
let socket_message = schema_for!(SocketMessage); #[cfg(feature = "schemars")]
let schema = serde_json::to_string_pretty(&socket_message)?; {
println!("{schema}"); let socket_message = schemars::schema_for!(SocketMessage);
let schema = serde_json::to_string_pretty(&socket_message)?;
println!("{schema}");
}
} }
SubCommand::StaticConfigSchema => { SubCommand::StaticConfigSchema => {
let settings = SchemaSettings::default().with(|s| { #[cfg(feature = "schemars")]
s.option_nullable = false; {
s.option_add_null_type = false; let settings = schemars::gen::SchemaSettings::default().with(|s| {
s.inline_subschemas = true; s.option_nullable = false;
}); s.option_add_null_type = false;
s.inline_subschemas = true;
});
let gen = settings.into_generator(); let gen = settings.into_generator();
let socket_message = gen.into_root_schema_for::<StaticConfig>(); let socket_message = gen.into_root_schema_for::<StaticConfig>();
let schema = serde_json::to_string_pretty(&socket_message)?; let schema = serde_json::to_string_pretty(&socket_message)?;
println!("{schema}"); println!("{schema}");
}
} }
SubCommand::GenerateStaticConfig => { SubCommand::GenerateStaticConfig => {
print_query(&SocketMessage::GenerateStaticConfig); print_query(&SocketMessage::GenerateStaticConfig);