FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
6.68k stars 97 forks source link

icon not fixed to space #424

Closed rwijtvliet closed 1 year ago

rwijtvliet commented 1 year ago

Excuse me in advance if this is a bit scatterbrained or already has a solution. I searched in the issue history but couldn't find anything related, though I assume I'm not the first person to experience it.

In yabai, I define several workspaces, e.g. 1_files, 2_www, etc. I also set-up key bindings in skhd to switch to these workspaces with hotkey+1, hotkey+2 etc. This works, and the correct workspace is focused, regardless of the monitor it's on or its current position in mission control.

My issue in sketchybar is that the icons/labels I assign each space are dependent on each space's position in mission control. If I move space 2_www, which has the firefox logo, to the next display, the firefox icon gets 'assigned' to the next workspace on the original monitor - i.e., to the one that takes its place in the mission control space order. The workspace 2_www now has the incorrect icon, too. (If I move the space back to the original monitor, the original order is not restored in mission control, but that is a yabai issue)

Is there a way to connect the space to a yabai space name?

rwijtvliet commented 1 year ago

Concretely:

currently, when starting sketchybar, all spaces are looped through, and assigned an icon in that order. The index number of the space is used as its identifier, but this number changes.

I was wondering if there is a more permanent identifier that can be used, e.g. the UUID or the yabai label - if these are accessible to the sketchybarrc script.

For my purposes, it is sufficient if the correct order is assumed when sketchybar is started (i.e., that the first space is indeed the one labelled 1_files, the second one is 2_www, etc.). But a more robust solution would be to create an associative SPACE_ICONS array, like so:

SPACE_ICONS=(
  1_files="1 <filebrowser icon>"
  2_www="2 <firefox icon>"
...
)
rwijtvliet commented 1 year ago

Thinking about it some more, yabai -m query --spaces could be used to find the relation between mission control index and yabai label. And the aforementioned associative array can be used to find the label to show in sketchybar.

It's a bit roundabout, but at least the information is there.