mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-28 11:22:47 +01:00
refactor(kde): use asc of komorebi-config
core::asc re-exports ApplicationSpecificConfiguration, AscApplicationRules and AscApplicationRulesOrSchema from komorebi-config; the local copy (60 lines) is removed. AscApplicationRules is now the union with the five Windows-only rule kinds: KDE only reads and writes its own, the others are None and skipped when written. A derived schema of the union would carry the Windows-only kinds and the x-komorebi-platforms markers, so the places that print or answer the applications schema ask for the KDE view instead: komorebic (application-specific-configuration-schema; komorebic gains the komorebi-config dependency, a two-line change in the arm) and the daemon's socket answer (same view, array form as before). This is the minimum change to komorebic that keeps its output; step 4 owns the rest of the file. Verified: KDE cargo check --workspace --all-targets: no warnings; cargo test -p komorebi --lib: 289 passed, 0 failed; --test schemas: 5 passed; komorebic regeneration: schema.asc.json byte-identical to the checked-in file (git: no diff against wip-main), schema.json only differs by the earlier description-only converge revisions.
This commit is contained in:
1 parent
2bd0269df6
commit
415e73a9ac
5 files changed
+15
-73
No files matched your search
Generated
+1
@@ -2629,6 +2629,7 @@ dependencies = [
|
|||||||
"fs-tail",
|
"fs-tail",
|
||||||
"komorebi",
|
"komorebi",
|
||||||
"komorebi-client",
|
"komorebi-client",
|
||||||
|
"komorebi-config",
|
||||||
"komorebi-hotkeys",
|
"komorebi-hotkeys",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"pastey",
|
"pastey",
|
||||||
|
|||||||
@@ -1,69 +1,8 @@
|
|||||||
//! The application specific configuration file (`app_specific_configuration_path`): rules, by
|
//! The application specific configuration file (`app_specific_configuration_path`): rules, by
|
||||||
//! application, for the windows komorebi ignores, manages or floats.
|
//! application, for the windows komorebi ignores, manages or floats.
|
||||||
|
//!
|
||||||
|
//! The types are defined in `komorebi-config`.
|
||||||
|
|
||||||
use crate::core::config_generation::MatchingRule;
|
pub use komorebi_config::asc::ApplicationSpecificConfiguration;
|
||||||
use color_eyre::Result;
|
pub use komorebi_config::asc::AscApplicationRules;
|
||||||
use serde::Deserialize;
|
pub use komorebi_config::asc::AscApplicationRulesOrSchema;
|
||||||
use serde::Serialize;
|
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::ops::Deref;
|
|
||||||
use std::ops::DerefMut;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
|
||||||
pub struct ApplicationSpecificConfiguration(pub BTreeMap<String, AscApplicationRulesOrSchema>);
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
|
||||||
#[serde(untagged)]
|
|
||||||
pub enum AscApplicationRulesOrSchema {
|
|
||||||
AscApplicationRules(AscApplicationRules),
|
|
||||||
Schema(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Deref for ApplicationSpecificConfiguration {
|
|
||||||
type Target = BTreeMap<String, AscApplicationRulesOrSchema>;
|
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DerefMut for ApplicationSpecificConfiguration {
|
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
||||||
&mut self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ApplicationSpecificConfiguration {
|
|
||||||
pub fn load(pathbuf: &PathBuf) -> Result<Self> {
|
|
||||||
let content = std::fs::read_to_string(pathbuf)?;
|
|
||||||
Ok(serde_json::from_str(&content)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn format(pathbuf: &PathBuf) -> Result<String> {
|
|
||||||
Ok(serde_json::to_string_pretty(&Self::load(pathbuf)?)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Rules that determine how an application is handled
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
|
||||||
pub struct AscApplicationRules {
|
|
||||||
/// Rules to ignore specific windows
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub ignore: Option<Vec<MatchingRule>>,
|
|
||||||
/// Rules to forcibly manage specific windows
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub manage: Option<Vec<MatchingRule>>,
|
|
||||||
/// Rules to manage specific windows as floating windows
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub floating: Option<Vec<MatchingRule>>,
|
|
||||||
/// Rules to identify applications which are title-less - only accepts Simple Exe rules
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub titleless: Option<Vec<MatchingRule>>,
|
|
||||||
/// Rules to identify applications which are title-less - only accepts Simple Exe rules
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub tabbed: Option<Vec<MatchingRule>>,
|
|
||||||
}
|
|
||||||
@@ -1858,10 +1858,10 @@ impl WindowManager {
|
|||||||
SocketMessage::ApplicationSpecificConfigurationSchema => {
|
SocketMessage::ApplicationSpecificConfigurationSchema => {
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
{
|
{
|
||||||
let asc = schemars::schema_for!(
|
let schema = komorebi_config::schema::view::<
|
||||||
Vec<crate::core::asc::ApplicationSpecificConfiguration>
|
Vec<crate::core::asc::ApplicationSpecificConfiguration>,
|
||||||
);
|
>(komorebi_config::schema::Platform::CURRENT);
|
||||||
let schema = serde_json::to_string_pretty(&asc)?;
|
let schema = schema.trim_end();
|
||||||
|
|
||||||
reply.write_all(schema.as_bytes())?;
|
reply.write_all(schema.as_bytes())?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ description = "The command-line interface for Komorebi, a tiling window manager
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
komorebi-config = { workspace = true }
|
||||||
komorebi = { path = "../komorebi", default-features = false }
|
komorebi = { path = "../komorebi", default-features = false }
|
||||||
komorebi-client = { path = "../komorebi-client", default-features = false }
|
komorebi-client = { path = "../komorebi-client", default-features = false }
|
||||||
komorebi-hotkeys = { path = "../komorebi-hotkeys" }
|
komorebi-hotkeys = { path = "../komorebi-hotkeys" }
|
||||||
|
|||||||
@@ -2179,9 +2179,10 @@ fn main() -> eyre::Result<()> {
|
|||||||
SubCommand::ApplicationSpecificConfigurationSchema => {
|
SubCommand::ApplicationSpecificConfigurationSchema => {
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
{
|
{
|
||||||
let asc = schemars::schema_for!(komorebi_client::ApplicationSpecificConfiguration);
|
let schema = komorebi_config::schema::view::<
|
||||||
let schema = serde_json::to_string_pretty(&asc)?;
|
komorebi_client::ApplicationSpecificConfiguration,
|
||||||
println!("{schema}");
|
>(komorebi_config::schema::Platform::CURRENT);
|
||||||
|
print!("{schema}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SubCommand::NotificationSchema => {
|
SubCommand::NotificationSchema => {
|
||||||
|
|||||||
Reference in new issue
Block a user