Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

[Feature Request] Order named workspaces

Open g33kex opened this issue 2 years ago • 4 comments

Hi! First of all thank you for your great work. I'm coming from sway and I was wondering if there could be an option to set the order of named workspaces.

Currently named workspaces (created with workspace name:MyName) are given an id in the order they are created, from -1337 and downwards. This means the last named workspace created will always be to the far left.

I like to have my named workspaces always in the same order, mail, then passwords, then web, then dev. In sway I was able to do that by setting the workspace names with ID:name, for instance 0:mail, 1:passwords, 2:web, 3:dev which would put them in that order. In Hyprland it doesn't seem to be possible to change the ID of a named workspace.

Would you consider allowing setting the ID of a named workspace, or even better, provide some command to set the named workspaces order? An command similar to wsbind could be used to bind a list of workspace to a in a certain order for instance.

For instance one would use wsorder=name:mail, name:passwords, name:web, name:develop which would then assign the ids of those named workspaces in that particular order when they're created.

Another perhaps simpler way would be to add the syntax ID:name to create a workspace or assign a window to a workspace like this:

windowrule=workspace -1:dev,foot
windowrule=workspace -2:web,firefox
windowrule=workspace -3:passwords,keepassxc
windowrule=workspace -4:mail,thunderbird

Please tell me if there's something I'm missing there.

g33kex avatar Sep 15 '22 00:09 g33kex

Another way this could be handled could be to allow workspace rules that set the id or name of a workspace with the other.

For example:

workspace = 1, name:mail # rule to set name for workspace with an id
workspace =  name:web, id:2 # rule to set an id for a workspace with a name

tmccombs avatar Jan 23 '24 07:01 tmccombs

I agree, I have tried switching to named workspaces multiple times but I always get workspaces lost when I try switching between them. I end up just using workspace ids 1-9 and just setting the name/icon in the statusbar instead which feels very hacky.

I sort of expected to be able to a workspace with ID 1 and name Web, etc. but can't seem to be able to achieve this in hyprland.

ArtemSmaznov avatar Feb 04 '24 17:02 ArtemSmaznov

renameworkspace? https://wiki.hyprland.org/Configuring/Dispatchers/

vaxerski avatar Feb 05 '24 01:02 vaxerski

That's a dispatcher.

I suppose you could have process that watches for the even of the workspace being created, and if the id matches, use hyprctl to rename the workspace. But that is a little inolved. Having a rule would be a lot simpler.

tmccombs avatar Feb 20 '24 06:02 tmccombs

workspace rules now support defaultName:[string]

So you can have your workspaces 1,2,3,4,5,6 etc with a rule to set their default names.

vaxerski avatar Feb 27 '24 22:02 vaxerski

workspace rules now support defaultName:[string]

So you can have your workspaces 1,2,3,4,5,6 etc with a rule to set their default names.

The behaviour here feels pretty weird.

If I have:

workspacerule = 1,defaultName:testworkspace

And I switch to workspace ID 1 via hyprctl dispatch workspace 1 all is as expected:

workspace ID 1 (testworkspace) on monitor eDP-1:
        monitorID: 0
        windows: 1
        hasfullscreen: 0
        lastwindow: 0x61d217b0c700
        lastwindowtitle: hyprctl:~ — Konsole

However if I attempt to switch to the workspace by name when the workspace is not active via hyprctl dispatch workspace name:testworkspace I end up on a new workspace with a random ID:

workspace ID -1337 (testworkspace) on monitor eDP-1:
        monitorID: 0
        windows: 1
        hasfullscreen: 0
        lastwindow: 0x61d217b0c700
        lastwindowtitle: hyprctl:~ — Konsole

I think most people are looking for a consistent binding between workspace ID and name.

The lack of consistent mapping is most problematic for me because workspace events only include the name, which forces consumers to operate on names, but names produce inconsistent results.

pdf avatar Feb 28 '24 13:02 pdf

named workspaces != ID-based workspaces.

You can stick to your IDs if you don't use named workspaces. Keep a registry somewhere, or call hyprctl workspaces and find the ID of the workspace by name.

Ordering purely name-based workspaces makes no sense.

Although events on socket2 probably should print the ID and not name, tbh

vaxerski avatar Feb 28 '24 14:02 vaxerski

named workspaces != ID-based workspaces.

I think that is pretty unintuitive. All workspaces have a name and an id (although for "named" workspaces, the id is negative). It seems odd to me that they would behave differently.

tmccombs avatar Feb 28 '24 17:02 tmccombs

There is no intuitive solution. All I can do is add a selector like wsName: for querying workspace by visible name, or print ids in events and add a selector like id: to explicitly specify an ID

vaxerski avatar Feb 28 '24 17:02 vaxerski

can stick to your IDs if you don't use named workspaces. Keep a registry somewhere, or call hyprctl workspaces and find the ID of the workspace by name.

Keeping a registry is complicated by the fact that there's no way to interrogate Hyprland for any name <-> ID mappings up-front if the workspaces are not active, and that IDs are random when working with names. Sorting also becomes very problematic because of the inconsistencies produced by switching/creating a workspace by ID, vs by name (and random IDs for name-based switching in general) - a defaultName'd workspace will change from e.g. ID 3 to ID -1337 depending on how it's instantiated, and then relative switching or visual representation order must change in a counter-intuitive way for the user.

There is no intuitive solution.

I guess this is complicated by the renameworkspace functionality, otherwise it would seem fairly straight-forward to always create a workspace with a consistent ID when switching by name if the config defines an ID <-> name binding, by maintaining a bi-directional map of that binding.

print ids in events and add a selector like id: to explicitly specify an ID

This probably solves most of the issues for my particular use-case and I'd like to see this happen regardless of where name mappings land as it would make interactions cleaner in general - I could use a purely ID-driven workflow and ignore the sharp edges produced by working with names. Can't speak to others' requirements though.

EDIT: This change to events would be breaking though, so probably requires new events with a version suffix.

pdf avatar Feb 28 '24 21:02 pdf

print ids in events and add a selector like id: to explicitly specify an ID

This probably solves most of the issues for my particular use-case and I'd like to see this happen regardless of where name mappings land as it would make interactions cleaner in general - I could use a purely ID-driven workflow and ignore the sharp edges produced by working with names. Can't speak to others' requirements though.

EDIT: This change to events would be breaking though, so probably requires new events with a version suffix.

Would you like me to write this up as a new issue so it can be tracked?

pdf avatar Mar 02 '24 20:03 pdf

feel free, probably beteter

vaxerski avatar Mar 02 '24 21:03 vaxerski

So what happen to this? Putting workspaces in a specific order is very important to me. config option <workspaceV2> does not exist.

Thank you for putting in the hard work in making this amazing compositor <3

CocolinoFan avatar Apr 16 '24 06:04 CocolinoFan

@CocolinoFan https://wiki.hyprland.org/Configuring/Window-Rules/ windowsrulev2 ? or workspacev2 is a thing now

kRHYME7 avatar Apr 18 '24 23:04 kRHYME7

@kRHYME7 Yep, windowrulev2 is a thing. But I am looking for workspaceV2 from issue 4929. What I want is simple: Make the named workspaces I create appear in a specific order.

P.S. I am 99.9% sure I am using the latest Hyprland commit. But would also be really nice if Hyprland --version was a thing.

CocolinoFan avatar Apr 19 '24 09:04 CocolinoFan

But I am looking for workspaceV2 from issue 4929.

Those are events, not configuration stanzas.

You can specify detault names for workspaces by ID using:

workspace=1,defaultName:foo
workspace=2,defaultName:bar

If your workspaces are ordered by ID in your keybinds (and you only use IDs in your binds, not names), and/or whatever graphical tool you use to represent them, then you'll get ordered workspaces.

P.S. I am 99.9% sure I am using the latest Hyprland commit. But would also be really nice if Hyprland --version was a thing.

hyprctl version is a thing.

pdf avatar Apr 19 '24 09:04 pdf