i3 / i3

A tiling window manager for X11
https://i3wm.org/
BSD 3-Clause "New" or "Revised" License
9.5k stars 780 forks source link

i3-msg "workspace number 32whatever" changes workspace 32's name. #5442

Open acidkewpie opened 1 year ago

acidkewpie commented 1 year ago

I'm submitting a…

[x] Bug
[ ] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Current Behavior

running i3-msg "workspace number 3" changes workspace 3's name to 3 running i3-msg "workspace number 32whatever" changes workspace 32's name to 32whatever

Expected Behavior

running i3-msg "workspace number 3" should change to workspace number 3, and NOT change its name running i3-msg "workspace number 32whatever" should fail as the workspace does not exist by name or number

The common behaviour here appears to be that it takes all the numbers at the start of the string and matches that to the workspace number, creating it if it does not already exist. Given this it NOT the rename command, even if it is deemed acceptable to derive the workspace number from its name, there appears to be no justification for the name to also be implicitly changed to match the string provided.

Whilst the second example is more... esoteric... the former has been a real pain for me to finally realise. Meshing this behaviour in with i3wsr, and loading startup apps on using this i3-msg approach i have to both call a workspace "3:" in my config and then also ensure I call i3-msg "workspace number 3:" in a script that loads certain apps in the right place order to not lose that colon, which is used later by polybar. Given there is a workspace which i3-msg -t get_workspaces reports as "num":3 I hope it feels reasonable for a user to presume running i3-msg "workspace number 3" would use that number, not the name, and certainly not change its name. I am aware there are more formal ways to load apps on specific workspaces, and in that case I'd be using $ws3 or such within the i3 config. However I don't think that inherently invalidates the logic / behaviour being questioned here.

As another take on this, there is this handy script from rofi. It only works using workspace numbers. As it wants an empty workspace it can not know the name that may or may not have been configured for it in i3. Maybe it has a chess icon assigned to the name, that seems popular..? But this script will wipe out any name you might want it to have.

Reproduction Instructions

Run commands as per examples above

Environment

Output of i3 --moreversion 2>&-:

Binary i3 version:  4.22 (2023-01-02) © 2009 Michael Stapelberg and contributors
Running i3 version: 4.22 (2023-01-02) (pid 56723)
Loaded i3 config:
  /home/chris/.config/i3/config (main) (last modified: Fri 03 Mar 2023 21:11:56 GMT, 699 seconds ago)

The i3 binary you just called: /usr/bin/i3
The i3 binary you are running: i3
- Linux Distribution & Version: Fedora 36
- Are you using a compositor (e.g., xcompmgr or compton): picom v10
i3bot commented 1 year ago

I don’t see a link to logs.i3wm.org. Did you follow https://i3wm.org/docs/debugging.html? (In case you actually provided a link to a logfile, please ignore me.)

Airblader commented 1 year ago

For the second case, I think there's a misunderstanding here of how i3 workspaces work.

as the workspace does not exist by name or number

i3 creates workspaces dynamically, so if it doesn't exist, it will be created (how would you otherwise even switch to a non-existing workspace in the first place).

Thus, workspace number 32whatever must create that workspace if it doesn't exist, not fail.


Your first case however is different and in direct contradiction to documented behavior:

Also, you will be able to use workspace number 1 to switch to the workspace which begins with number 1, regardless of which name it has.

It's possible this is some unconsidered special case since you're using an empty string after the colon, but I can't verify.

acidkewpie commented 1 year ago

Yes, I was just about to nuke this, didn't expect a reply so soon. :)

I think my fundamental confusion is that defining a ws name in the config file doesn't really mean anything until it exists. You can set a name for the future, but that doesn't really mean much. So that first case doesn't hold up. I was basing my expectations on the fact I has a name of "3:" defined in my config, but there's nothing to care about that whilst empty. However it did lead me to see that a workspace name is not necessarily unique?

If I run i3-msg workspace 3whatever, removing "number" then if ws 3 already exists I instead get a SECOND workspace 3 with this new name. That does seem wonky, but maybe that will be justified shortly too! :D

Airblader commented 1 year ago

Workspace names are unique, but the workspace name for numbered workspaces includes the number, so "3:foo" and "foo" are different names even if you don't display workspace numbers. What isn't unique is the numbers — you can have multiple workspaces with num 3.