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

Sway workspaces #191

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Sway workspaces #191

wants to merge 5 commits into from

Conversation

mildred
Copy link
Contributor

@mildred mildred commented Mar 13, 2023

Fixes #189 and #190

@mildred
Copy link
Contributor Author

mildred commented Mar 13, 2023

This is implemented on top of #188 ... if #188 is not merged, then I'll rebase to remove unwanted commits

@mildred mildred marked this pull request as ready for review March 13, 2023 18:24
@mildred mildred mentioned this pull request Mar 13, 2023
mildred added 5 commits March 13, 2023 19:25
- sort workspaces number from sway to show them in correct order
- fix configuration interface
- handle workspaces labels in config
- handle workspaces labels from sway if not defined in config
@mildred mildred mentioned this pull request Mar 13, 2023
@cinghiopinghio
Copy link

It works for me.

With this config:

    "sway-workspaces": {
      "numbers": [],
      "custom-labels": [
        "O"
      ],
      "focused-labels": [
        "X"
      ],
      "show-icon": true,
      "image-size": 16,
      "show-name": true,
      "name-length": 40,
      "mark-autotiling": true,
      "mark-content": true,
      "show-layout": true,
      "angle": 0.0
    },

I have this:

image

if num in self.settings["numbers"]:
config_idx = self.settings["numbers"].index(num)
elif len(self.settings["numbers"]) == 0:
config_idx = num - 1
Copy link
Contributor

@moetayuko moetayuko Apr 25, 2023

Choose a reason for hiding this comment

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

settings["numbers"] is stored as a list of str, int-based lookup fails here

text = labels[config_idx]
elif labels and len(labels) == 1:
text = labels[0]
elif idx in range(len(ws_defs)):
Copy link
Contributor

Choose a reason for hiding this comment

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

default value of ws_defs is None, which has no len()

ws_num, win_name, win_id, non_empty, win_layout, numbers, ws_defs = self.find_details()

custom_labels = self.settings["custom-labels"]
focused_labels = self.settings["focused-labels"]
Copy link
Contributor

Choose a reason for hiding this comment

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

not accessed

ws_num, win_name, win_id, non_empty, win_layout, numbers, ws_defs = self.find_details()

custom_labels = self.settings["custom-labels"]
focused_labels = self.settings["focused-labels"]

if len(self.settings["numbers"]) > 0:
numbers = self.settings["numbers"]
Copy link
Contributor

Choose a reason for hiding this comment

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

if numbers is set in config, it's not guaranteed to match ws_defs

@nwg-piotr
Copy link
Owner

Thank you, @moetayuko

Comment on lines +128 to +131
if focused:
labels = self.settings["focused-labels"]
else:
labels = self.settings["custom-labels"]
Copy link
Contributor

Choose a reason for hiding this comment

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

previously it fallbacks to custom-labels if focused-labels not defined, need to implement this as well.

@moetayuko
Copy link
Contributor

moetayuko commented Apr 25, 2023

split from #188 and rebased on master at https://github.com/MoetaYuko/nwg-panel/tree/sway-workspaces, and addressed the issues I commented above. please test if its behavior is still desired.


I noticed the following issues with both my rebased branch and @mildred 's original branch

  1. gray vertical line beside hidden labels
    图片
  2. The order is still incorrect if numbers are not specified in config (so that labels are not populated in build_box).
    "sway-workspaces": {
      "numbers": [],
      "custom-labels": [],
      "focused-labels": [],
      "hide-empty": true,
      "hide-other-outputs": true
    },

in the following example, 368 are non-empty at nwg-panel start time so they occur first, 14 are switched to later so they come after 368, which is undesired. need to reimplement the mapping between ws number and gtk.label
图片

@nwg-piotr
Copy link
Owner

please test if its behavior is still desired

I don't use this module in real life, and the code contains some contributed changes not always in line with my original concept. It would be better if further changes would be discussed by real life users.

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.

[bug] Setting empty workspaces to hide
4 participants