Skip to content
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

[BUG] workspaces with "hide empty" do not respect custom-labels and focused-labels #190

Open
cinghiopinghio opened this issue Mar 9, 2023 · 15 comments

Comments

@cinghiopinghio
Copy link

Describe the bug
After the merging on #184 we have hide empty workspaces feature which is achievable with an empty list in numbers
Setting an empty list manually as in #189 results in the module not respecting the custom-labels and focused-labels, I only see numbers.
Moreover the numbers are not sorted.

To Reproduce
Steps to reproduce the behavior:

  1. open config with an editor
  2. go to sway-workspaces.numbers and set it to an empty list [].
  3. set sway-workspaces.custom-labels and sway-workspaces.focused-labels to some glyph.
  4. start nwg-panel
  5. See error

Expected behavior
Workspaces shoud be sorted.
Workspeces labels should follow the settings

Screenshots

image

Desktop (please complete the following information):

  • Linux distribution: Archlinux
  • Sway version sway -v: 1.8.1
  • Panel version nwg-panel -v: 0.8.0

Additional context
It may be related to https://github.com/mildred/nwg-panel/blob/01811b84fb4872d3560b8faa08ea337f322fe402/nwg_panel/modules/sway_workspaces.py#L128 where the loop goes over the settings["numbers"] which in this case is an empty list.
Not sure though.

@nwg-piotr
Copy link
Owner

@mildred

@mildred
Copy link
Contributor

mildred commented Mar 13, 2023

I'm unsure how to implement this as for me the custom-labels should match the workspaces in numbers. If the numbers list is empty (which I implemented) this means a dynamic workspaces list, then how to match the actual workspace number to the label in configuration?

In that case, we could consider that custom-labels should match workspace number considering the first workspace being number 1 (or 0 ?)

Also, is there a reason not to use the Sway workspace labels and duplicate the workspace label in nwg-panel configuration? Wouldn't it be more useful to remove the custom labels and use the Sway configured labels instead?

@nwg-piotr
Copy link
Owner

I don't use this module much, but - if I remember well - what I had in mind were people who use glyphs or short textual labels like e.g. "Web".

@mildred
Copy link
Contributor

mildred commented Mar 13, 2023

Yep, but this is already configurable in Sway config. When you use 1:name in the sway config, this means that the workspace number 1 has the name name.

The focused-label is is not however configurable in Sway anthough scripts must exists to rename workspaces on the fly.

@nwg-piotr
Copy link
Owner

Keep in mind that every single script in nwg-shell uses workspace numbers, never names.

@cinghiopinghio
Copy link
Author

For what I understood, with an explicit list in numbers we could:

  1. leave custom-labels empty, hence we have numbers in the module
  2. provide ONE glyph this would be repeated for all ws (this was my use case: I have one glyph for all ws and another for the focused one)
    image
  3. provide a list of glyphs of the same length numbers to have the ws matched.

(TBH I never checked a list of glyphs of different length)

In the new case of empty numbers I would:

  • try to reproduce my use case (2), one glyph to rule them all (except for the focused ws)
  • ask for a list of custom-labels and match that to the numbers from 1 to 8 (if a ws is absent, the corresponding glyph would be absent).

@mildred
Copy link
Contributor

mildred commented Mar 13, 2023

I suggest if numbers is empty:

  • if show-name is true and we can match the workspace in the custom-labels or focused-labels (starting at workspace 1 being the first), use the label provided in the config
  • if show-name is true but we cannot find the custom label in the nwg-panel config, use the Sway workspace name (the part after the :)
  • else use the number

You could implement your use-case by duplicating the glyph you want to use in custom-labels and focused-labels enough to match the max number of workspaces you'll ever have.

@mildred
Copy link
Contributor

mildred commented Mar 13, 2023

Also, what about ignoring workspaces that are not on the current output when using a dynamic numbers list ?

@cinghiopinghio
Copy link
Author

What @mildred propose seems OK to me.

@nwg-piotr
Copy link
Owner

nwg-piotr commented Mar 13, 2023

This module is getting way too complicated to my taste, but I don't use it anyway. @mildred, give it a go, we'll see how it behaves.

@mildred
Copy link
Contributor

mildred commented Mar 13, 2023

I'll try to come up with somethig not too complex. Looking at the code, the config is made so if the focused-labels or custom-labels have only one elements, this elements serves as default for all.

@mildred
Copy link
Contributor

mildred commented Mar 13, 2023

I can try and refactor the module also, but I'll first come with a non refactored version

@cinghiopinghio
Copy link
Author

If you (@mildred ) need some help, just ask. I can do some python or test.

@mildred
Copy link
Contributor

mildred commented Mar 13, 2023

Can you test out the sway-workspaces branch here?

master...mildred:nwg-panel:sway-workspaces

edit: just checkout and run PYTHONPATH=. python3 ./nwg_panel/main.py

@cinghiopinghio
Copy link
Author

Sorry for the delay, I was out.
I commented in the PR that I seams to work, even with only one character.

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

No branches or pull requests

3 participants