-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow workspace names to be changed dynamically #904
base: main
Are you sure you want to change the base?
Conversation
src/layout/mod.rs
Outdated
// ignore request if the name is an integer | ||
if name.parse::<usize>().is_ok() { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? I believe you can name workspaces as numbers in the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intended to avoid confusion with other auto-named workspaces. Having two different namespaces keeps things simple. I'm not sure how things are dealt with (possibly very well ;-) when a wkspc is automatically assigned a value that might already be used as an assigned name.
src/layout/mod.rs
Outdated
@@ -3394,6 +3394,26 @@ impl<W: LayoutElement> Layout<W> { | |||
monitor.move_workspace_up(); | |||
} | |||
|
|||
pub fn set_workspace_name(&mut self, name: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please add these two operations to the Op
enum below so they can participate in the randomized tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two tests I put in are kind of trivial, they may not clear your bar for completeness/quality.
There is an issue when the last workspace has its name set. Based on asserts in test cases, the last item in any monitor's workspace vec must be an unnamed workspace. With the as-is PR, this property is no longer always verified. |
src/layout/monitor.rs
Outdated
pub fn unname_workspace_with_filter<P>(&mut self, pred: P) -> bool | ||
where | ||
P: Fn(&Workspace<W>) -> bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about instead of accepting a generic predicate here and in set_workspace_name()
, just always accept a WorkspaceId
? I think it should make things simpler. And it's not like this can ever be called for multiple workspaces at once (and even then, it would be safer to call it for them one-by-one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried something, can't say I'm really convinced it's much better. Maybe I'm not looking at it the right way.
9bc72c4
to
951eedb
Compare
Pushed a few cleanups, should be good to merge now. Do you mind testing one more time? |
Will do! |
One final change, made the workspace reference a non-positional option to make it less confusing what goes where (i wrote that commit message the opposite way, huh). Let's merge this |
A trivial PR that adds
set-workspace-name
andunset-workspace-name
actions.This is really nifty when combined with the Waybar Niri workspace module.