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

feat: Ability to use icons for empty workspace. #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pierrechevalier83
Copy link
Owner

This allows users of ex. waybar to use dynamic icons, while still giving empty workspaces an icon instead of a number. This is implemented by renaming new workspaces right when they are created.
This is all behind a config option; defaults remain unchanged.

Implementing this is also an optimization for the rest of the program, which no longer recalculates workspace naming on every Event::Window. Instead, only specific Window (and now also Workspace) events will do so.

Caveats:

  • There is a small visual artifact when opening a new workspace, when the number gets renamed to the desired icon.. Unfortunately, being a program reacting to sway events, I don't see a way to fix this.

Future Possibilities:

  • Allowing specific icons for specific numbered (empty) workspaces wouldn't be difficult to add (which would close Persistent workspaces #33).
  • Which *.change types precisely should trigger workspace renaming was determined with common sense, and could do with a one-over. The relevant function is should_rename_after_event.

Closes #39.

This allows users of ex. `waybar` to use dynamic icons,
while still giving empty workspaces an icon instead of a number.
This is implemented by renaming new workspaces right when they
are created.
This is all behind a config option; defaults remain unchanged.

Implementing this is also an optimization for the rest of the program,
which no longer recalculates workspace naming on _every_ `Event::Window`.
Instead, only specific `Window` (and now also `Workspace`) events
will do so.

**Caveats**:
- There is a small visual artifact when opening a new workspace,
when the number gets renamed to the desired icon.. Unfortunately,
being a program reacting to sway events, I don't see a way to fix this.

**Future Possibilities**:
- Allowing specific icons for specific numbered (empty) workspaces
wouldn't be difficult to add (which would close #33).
- Which `*.change` types precisely should trigger workspace renaming
was determined with common sense, and could do with a one-over.
The relevant function is `should_rename_after_event`.

Closes #39.
@pierrechevalier83
Copy link
Owner Author

Hi @so-rose 👋

I think this should be logically equivalent to the previous code in #42.

Originally, I tried to move the part where we listen for events before displaying anything because that means that when we start workstyle, we don't refresh workspaces the first time. That can be fixed differently by refreshing before entering the loop, so needs to be addressed before we merge this, but not a major issue.

I played with it in hyprland (waybar doesn't have persistent workspaces for it yet, but there is a PR up so that should happen soon) and sway trying to find some settings between waybar, workstyle and sway that make persistent workspaces work with this.

My attempts revolved around this bit of waybar config or something along those lines

    "sway/workspaces": {
         "disable-scroll": false,
         "all-outputs": false,
         "format": "{name}",
         "persistent_workspaces": {
            "1:  ": ["DP-5"],
            "2:  ": ["DP-5"],
            "3:  ": ["DP-5"],
            "4:  ": ["DP-5"],
            "5:  ": ["DP-5"],
            "6:  ": ["eDP-1"],
            "7:  ": ["eDP-1"],
            "8:  ": ["eDP-1"],
            "9:  ": ["eDP-1"],
            "10:  ": ["eDP-1"],
        },
     },

From my testing, this is a bit of a step in the right direction, but the behaviour is really buggy and unpredictable.
For instance, sometimes it would behave correctly, but sometimes it would move you around when you try to create a new workspace.

Am I missing something? @so-rose, could you share the config settings you have in mind for sway + waybar + workstyle that would make it work?

It could also be that I butchered something in the rebase.

Also, I've been playing with it on multiple monitors to try and catch more potential edge-cases, but I'm also seeing many buggy behaviours on a single monitor.

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.

Keep workspace icon instead of number with waybar? Persistent workspaces
2 participants