feat: WindowRules Workspace Assignment#2214
Open
karlskewes wants to merge 3 commits into
Open
Conversation
5 tasks
dea7d43 to
8198d24
Compare
69a1fd3 to
ba1e37d
Compare
Author
|
Removed formatting commit, reduced Cargo changes and rebased. |
3e1640f to
13259ed
Compare
13259ed to
0a97a12
Compare
estin
added a commit
to estin/cos-cli
that referenced
this pull request
Apr 16, 2026
d4087fc to
e4db93b
Compare
Author
$ nix-shell -p wayland pkg-config
[nix-shell:~/src/github.com/karlskewes/cosmic-protocols]$ cargo run --example toplevel-list
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
Running `target/debug/examples/toplevel-list`
Toplevel ObjectId(zcosmic_toplevel_handle_v1@4278190080)
Title: Some("cargo run --example toplevel-list")
App ID: Some("kitty")
States: [Activated]
Outputs: []
Workspaces: []
Toplevel ObjectId(zcosmic_toplevel_handle_v1@4278190081)
Title: Some("feat: WindowRules Workspace Assignment by karlskewes · Pull Request #2214 · pop-os/cosmic-comp — Mozilla Firefox")
App ID: Some("firefox")
States: []
Outputs: []
Workspaces: [] |
Workspace Assignments are a new feature enabling applications to be
consistently launched automatically onto a specific workspace ID.
This commit enables loading assignments from a new location on disk:
`com.system76.CosmicSettings.WindowRules/v1/workspace_assignment_custom`
For example:
```sh
$ cat $HOME/.config/cosmic/com.system76.CosmicSettings.WindowRules/v1/workspace_assignment_custom
[
(
enabled: true,
appid: ".*",
title: ".*kitty.*",
workspace_id: "11f90a5"
),
(
enabled: true,
appid: ".*",
title: ".*firefox.*",
workspace_id: "b382cb"
)
]
```
This file is also watched for changes which invoke a reload of current
assignments.
Default (CosmicDE defined) assignments are not currently supported but
code and filenames have been chosen to avoid a conflict with the
standard naming.
Start application/window on workspace if it exists. In practice, pinned workspaces with workspace id's matching the workspace assignment id are required. Behaviours: 1. If the assigned workspace doesn't exist then the window is launched on the current active workspace. This was the behaviour before this commit. 2. If the assigned workspace does exist, then the window is launched on the workspace but the workspace is not made active. On a single screen this may result in the window launching silently onto a "background workspace".
Switch to pinned revision when merged.
e4db93b to
ffcec17
Compare
Author
|
When #2427 lands I will rework this to match on workspace names instead. Assign to first matching workspace name (assuming duplicates could exist?). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
Feature
Extend
WindowRulesenabling launching applications on specific workspaces instead of the current active workspace.Requires: pop-os/cosmic-settings-daemon#137
How to use
Get Application ID and Title:
Deprecated but works, see: pop-os/cosmic-protocols#70 (comment)
Pin workspaces using UI or via file:
Define Workspace Assignment configuration file with matching
id's, regex supported:Disable the window rule by setting
enabled: false.Behaviours
For example, if workspaces
aandbexist but the application config pins toc, then workspacecwill NOT be added.2026-03-20T21:37:45.920671Z WARN cosmic_comp::shell: Assigned workspace id not found: foobar1b, launch Firefox pinned toc, active workspace stays onb.workspace_assignment_customis auto-reloaded when the file changes however existing windows are not moved if the assigned workspace id was changed.terminal,browser,work.workspace.id's are created with a random generator when using UI to pin.Testing
flake.nix->nix developWhen rebased onto: #2219 and using pop-os/cosmic-settings-daemon#138
flake.nix->nix buildWhen rebased onto: #2219 and using pop-os/cosmic-settings-daemon#138
# build cosmic-comp nix buildCan't run the resulting binary because of missing dependencies/version clashes.
NixOS package overlay
UI Component
Whilst the configuration file support in this PR is sufficient for my use case, I saw mention of UI support for a similar feature in: #1292 (comment)
Could that be this? pop-os/cosmic-settings#438
Something I could pickup next perhaps. Or other window rules.
Note to reviewers
This is my first contribution to Cosmic and I may have misunderstood or completely missed project structure/styling or other conventions. Please let me know and I'll rework accordingly. Thank you!
assign [class="<application_class>"] <workspace_number>path/to/WindowRules/workspace_assignment_custombecause it appears to be convention to have a file per feature, rather than a catch all../WindowRules/window_ruleswith features: sticky, tiling exceptions, workspace assignment, etcworkspace_assignment_defaultsfree for implementation if required.AI Disclosure
No AI generated code in the development of this PR.