mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-20 07:41:25 +02:00
feat(wm): add workspace rules
This feature allows users to specify which monitor/workspace an application's window, identified either by executable name or window class name, should be assigned to. A new fn, WindowManager.enforce_workspace_rules, is called whenever a new rule is added, and periodically whenever an event is processed by komorebi (just after orphan windows are repead, before the matching and processing of the specific event). Both class and exe identifiers are stored in the same HashMap for the sake of simplicity, as I couldn't think of any situations where there might be a clash between the two identifiers. Did some light refactoring of window_manager.rs to make the new() constructor a static method on the WindowManager struct. Also fixed a bug in Workspace.new_container_for_window where the focused index was not getting set correctly when the workspace had no containers.
This commit is contained in:
@@ -165,6 +165,18 @@ struct ApplicationTarget {
|
||||
id: String,
|
||||
}
|
||||
|
||||
#[derive(Clap)]
|
||||
struct WorkspaceRule {
|
||||
#[clap(arg_enum)]
|
||||
identifier: ApplicationIdentifier,
|
||||
/// Identifier as a string
|
||||
id: String,
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
/// Workspace index on the specified monitor (zero-indexed)
|
||||
workspace: usize,
|
||||
}
|
||||
|
||||
#[derive(Clap)]
|
||||
#[clap(author, about, version, setting = AppSettings::DeriveDisplayOrder)]
|
||||
struct Opts {
|
||||
@@ -265,6 +277,9 @@ enum SubCommand {
|
||||
/// Add a rule to always float the specified application
|
||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||
FloatRule(ApplicationTarget),
|
||||
/// Add a rule to associate an application with a workspace
|
||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||
WorkspaceRule(WorkspaceRule),
|
||||
/// Identify an application that closes to the system tray
|
||||
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
|
||||
IdentifyTrayApplication(ApplicationTarget),
|
||||
@@ -413,6 +428,12 @@ fn main() -> Result<()> {
|
||||
send_message(&*SocketMessage::FloatTitle(arg.id).as_bytes()?)?;
|
||||
}
|
||||
},
|
||||
SubCommand::WorkspaceRule(arg) => {
|
||||
send_message(
|
||||
&*SocketMessage::WorkspaceRule(arg.identifier, arg.id, arg.monitor, arg.workspace)
|
||||
.as_bytes()?,
|
||||
)?;
|
||||
}
|
||||
SubCommand::Stack(arg) => {
|
||||
send_message(&*SocketMessage::StackWindow(arg.operation_direction).as_bytes()?)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user