Skip to content

Conversation

@oisanjaya
Copy link

This PR enable workspace reference by ID for operations on niri msg action.

My idea was using id: prefix to refer workspace by its id instead of index, this is done in niri-ipc/src/lib.rs from_str trait implementation, that is checks user arguments; if it is integer number then assume user refer to index (to maintain backward compatibility of current operations); if it is prefixed by id: then assume user refering workspace's id; else assume name reference.

This PR also change niri msg workspaces command output to include workspace's id.

@oisanjaya oisanjaya marked this pull request as draft November 20, 2025 11:55
@oisanjaya oisanjaya marked this pull request as ready for review December 21, 2025 17:36
}
} else {
Self::Name(s.to_string())
if s.starts_with("id:") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using s.strip_prefix("id:") might be better here since it avoids slicing by index (s[3..])

Reduce nesting by splitting Index and Id cases into two separate if block could also be nice, but that’s probably a detail

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on strip_prefix, but keep nested if for now as it would result fewer checks, let's see how others opinion.

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.

2 participants