From 07fb9aec6db0fde0df648518563db6557f4b122c Mon Sep 17 00:00:00 2001 From: Karl Skewes Date: Sat, 14 Mar 2026 16:50:23 +1000 Subject: [PATCH 1/2] feat: new Window Rule Workspace Assignment Config Workspace Assignments are a new feature enabling applications to be consistently launched automatically onto a specific workspace ID. This commit includes the config structs and getter functions for storing assignments, e.g: `com.system76.CosmicSettings.WindowRules/v1/workspace_assignment_custom` Default (CosmicDE defined) assignments are not currently supported but code and filenames have been chosen to avoid a conflict with the standard naming. --- config/src/window_rules/mod.rs | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/config/src/window_rules/mod.rs b/config/src/window_rules/mod.rs index 496e09e4..a1e76299 100644 --- a/config/src/window_rules/mod.rs +++ b/config/src/window_rules/mod.rs @@ -35,12 +35,21 @@ pub struct PreciseApplicationException { pub enabled: bool, } +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +pub struct WorkspaceAssignment { + pub appid: String, + pub title: String, + pub enabled: bool, + pub workspace_id: String, +} + // cosmic-config configuration state for `com.system76.CosmicSettings.WindowRules` #[derive(Clone, Debug, Default, PartialEq, CosmicConfigEntry)] #[version = 1] pub struct Config { pub tiling_exception_defaults: Vec, pub tiling_exception_custom: Vec, + pub workspace_assignment: Vec, } impl Config { @@ -117,3 +126,37 @@ pub fn tiling_exceptions(context: &cosmic_config::Config) -> Vec Vec { + // Load custom assignments defined by the user. + let custom = context + .get::>("workspace_assignment_custom") + .unwrap_or_else(|why| { + if why.is_err() + && let cosmic_config::Error::GetKey(_, err) = &why + && err.kind() != std::io::ErrorKind::NotFound + { + tracing::error!("workspace assignment custom config error: {why}"); + return Vec::new(); + } + tracing::debug!("workspace assignment custom config not present: {why}"); + Vec::new() + }); + + custom + .iter() + .filter_map(|assignment| { + if assignment.enabled { + Some(WorkspaceAssignment { + appid: assignment.appid.clone(), + title: assignment.title.clone(), + enabled: true, // Currently unused. + workspace_id: assignment.workspace_id.clone(), + }) + } else { + None + } + }) + .collect() +} From 875511967217707ded550794621edd688b388a4a Mon Sep 17 00:00:00 2001 From: Karl Skewes Date: Fri, 26 Jun 2026 12:03:46 +1000 Subject: [PATCH 2/2] refactor: match Workspaces by name instead of id --- config/src/window_rules/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/src/window_rules/mod.rs b/config/src/window_rules/mod.rs index a1e76299..5074b22a 100644 --- a/config/src/window_rules/mod.rs +++ b/config/src/window_rules/mod.rs @@ -40,7 +40,7 @@ pub struct WorkspaceAssignment { pub appid: String, pub title: String, pub enabled: bool, - pub workspace_id: String, + pub workspace_name: String, } // cosmic-config configuration state for `com.system76.CosmicSettings.WindowRules` @@ -152,7 +152,7 @@ pub fn workspace_assignments(context: &cosmic_config::Config) -> Vec