FelixKratz / SketchyBar

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

[enhancement?] distinct bar color per display #437

Closed rwijtvliet closed 11 months ago

rwijtvliet commented 11 months ago

I think this is currently not possible, but I thought I'd ask.

My setup:

I have a color associated with each space, which I use for the background of that space's space item - if that space has focus. For example, here I have space 2 (orange) active on my primary display....

image

...and space 9 (green) on my secondary one:

image

My issue/question/enhancement:

I'd like to make the color more prominent, and color the entire bar with it. So, on the primary display, it should be orange, and on the secondary, green.

What I've tried:

1: Setting the bar color directly

Using sketchybar --bar color=$color.

This changes the color on both displays, so cannot be used. Again the primary display...

image

...and the secondary one:

image

2: Using an item.

Items can be restricted to show only on a space/display, and I could set its background color.

This didn't work because I couldn't find out how to make the item stretch to fill up any "unclaimed" space on the bar.

(solution 2 would look different, as it would only color the unused part of a bar, but that is fine too)


I guess I'm pushing the limits of what this project is trying to accomplish, so if it's not a considered use-case, that's totally fine.

rwijtvliet commented 11 months ago

Why do always start reading the docs after writing a question?

I could probably get something to work using this. However, I think it's not possible without duplicating my code base and changing every mention of sketchybar to secondary_bar (or something), which is less than ideal for maintenance.

FelixKratz commented 11 months ago

There are a number of ways you could achieve what you would like to have.

I think the simplest would be to use the bracket special item: With it you can connect two arbitrary items with a common background, i.e. adding this after all other items have been added will fill the gap between them

sketchybar --add item left_anchor left \
           --set left_anchor width=0 display=1 \
           --add item right_anchor right \
           --set right_anchor width=0 display=1 \
           --add bracket gap_fill left_anchor right_anchor \
           --set gap_fill background.color=0xff00ff00
Screenshot 2023-11-10 at 00 05 16

If instead you add this before adding any other items, you will end up with this:

Screenshot 2023-11-10 at 00 06 17

As you can see, these items are only displayed on display 1, so you can do the same for any other displays you would like to have this colored bar appear on and change the color of the respective bracket accordingly.

rwijtvliet commented 11 months ago

That's really clever! Thanks once more for such a fast answer, it's really appreciated!

rwijtvliet commented 11 months ago

...and will you look at that <3

image image