Skip to content

feat: per-application workspace assignment rules - #2556

Open
AldenDana wants to merge 5 commits into
pop-os:masterfrom
AldenDana:workspace-assignments
Open

feat: per-application workspace assignment rules#2556
AldenDana wants to merge 5 commits into
pop-os:masterfrom
AldenDana:workspace-assignments

Conversation

@AldenDana

@AldenDana AldenDana commented Jul 11, 2026

Copy link
Copy Markdown

Implements pop-os/cosmic-epoch#1395 / pop-os/cosmic-workspaces-epoch#186: opening an app always places it on a chosen workspace.

Adds a workspace_assignments config to com.system76.CosmicComp — a list of (app_id, workspace) rules (workspace numbers 1-based, matching the UI). When a new window's app_id matches, it maps to that workspace instead of the active one, regardless of launch origin; the target workspace is flagged urgent rather than stealing focus (same behavior as other windows mapped to inactive workspaces). Rules hot-reload like other compositor settings.

Rules can be managed from the window context menu: right-click a titlebar → Always open on this workspace toggles a rule for that app on the window's current workspace (the entry then shows Always opens on workspace N with a checkmark). The menu writes through cosmic-config, so the config file stays the single source of truth:

// ~/.config/cosmic/com.system76.CosmicComp/v1/workspace_assignments
[
    (app_id: "code", workspace: 5),
]

Alt+Space opens the window menu. Not every window has a compositor-drawn titlebar to right-click — client-side-decorated windows (most GTK4/Qt6/Electron/libcosmic apps, including COSMIC's own Files) have none, so there was previously no way to reach the context menu (and therefore the workspace-assignment toggle) for them at all. Alt+Space is added as a hardcoded, non-configurable compositor shortcut (PrivateAction::OpenWindowMenu) that opens the menu for the currently focused window regardless of decoration mode — chosen because it's unused by default and is the traditional "window system menu" shortcut on other desktops (Super+M was the first attempt, but that's already bound to Maximize by default, so it's Alt+Space instead).

Rename support. The zcosmic_workspace_handle_v2::rename request was defined in the protocol but never handled compositor-side; this wires it up (advertises the Rename capability, applies the name, and persists it for pinned workspaces) so clients can let users rename workspaces.

Happy to follow up with a cosmic-settings page for bulk management if the config shape is acceptable.

@AldenDana

Copy link
Copy Markdown
Author

AI disclosure

This implementation was developed with assistance from Claude (Anthropic's AI coding assistant), directed and reviewed by me throughout — I specified the requirements, reviewed the generated diffs, and tested every feature live on my own machine. I'm continuing to work with Claude to address review feedback, so turnaround should be quick either way.

  • I have disclosed use of any AI generated code in my commit messages.
    • (Disclosing here in the PR rather than retroactively rewriting already-pushed commit messages.)
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

Adds a workspace_assignments config (list of app_id -> workspace
number, 1-based) to com.system76.CosmicComp. When a new window's
app_id matches a rule, it is mapped to the configured workspace
instead of the active one, regardless of how the app was launched.
The target workspace is flagged urgent rather than stealing focus,
matching existing behavior for windows mapped to inactive workspaces.

Rules hot-reload via cosmic-config like other compositor settings.

Example (~/.config/cosmic/com.system76.CosmicComp/v1/workspace_assignments):
[
    (app_id: "code", workspace: 5),
]

Implements pop-os/cosmic-epoch#1395 / pop-os/cosmic-workspaces-epoch#186.

AI-assisted commit: implemented with Claude (Anthropic's AI coding assistant); the author directed the requirements, reviewed the generated diff, and tested the resulting behavior.
Adds an 'Always open on this workspace' toggle to the window menu,
next to 'Always on Visible Workspace'. Pinning stores an
(app_id, workspace) rule in workspace_assignments via cosmic-config
(so it hot-reloads and stays the single source of truth); the entry
then reads 'Always opens on workspace N' with a checkmark, and
clicking it again removes the rule.

AI-assisted commit: implemented with Claude (Anthropic's AI coding assistant); the author directed the requirements, reviewed the generated diff, and tested the resulting behavior.
Right-click on the title bar only reaches windows using server-side
decoration. Most modern apps (GTK4, Qt6, Electron, libcosmic itself)
draw their own client-side title bar, so the compositor renders none
for them and there was previously no way to reach this menu at all
for such windows - including the 'Always open on this workspace' item
from the workspace-assignments branch.

Hardcoded to Super+M (bypassing the configurable shortcuts system,
which lives in a separate crate) since it's compositor-internal,
mirroring the existing pattern for Escape/Resizing PrivateActions.
Opens at the focused window's top-left corner; menu_request already
derives the rest of the window's geometry from the surface.

AI-assisted commit: implemented with Claude (Anthropic's AI coding assistant); the author directed the requirements, reviewed the generated diff, and tested the resulting behavior.
Advertise the Rename capability and act on zcosmic_workspace_handle_v2
rename requests: update the in-memory workspace name and persist it
for pinned workspaces, mirroring how pinned state is already saved.

AI-assisted commit: implemented with Claude (Anthropic's AI coding assistant); the author directed the requirements, reviewed the generated diff, and tested the resulting behavior.
Super+M is already bound to Maximize by default
(com.system76.CosmicSettings.Shortcuts/v1/defaults). The hardcoded
intercept ran before the configurable shortcuts lookup, so it silently
swallowed the keypress and broke Maximize. Alt+Space is unused and is
the traditional "open window system menu" shortcut.

AI-assisted commit: implemented with Claude (Anthropic's AI coding assistant); the author directed the requirements, reviewed the generated diff, and tested the resulting behavior.
@AldenDana
AldenDana force-pushed the workspace-assignments branch from a692266 to b5a6da2 Compare July 13, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant