FelixKratz / SketchyBar

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

ER: Support for multiple bars #353

Closed peterhajas closed 1 year ago

peterhajas commented 1 year ago

I didn't find a prior issue or documentation about this.

It'd be great if Sketchybar supported multiple named bars. For example:

This could likely be extended to the current syntax by naming the bar (where the default is --bar). For example:

sketchybar --bar=secondary set color=...
sketchybar --bar=tertiary --add item asdf ...
FelixKratz commented 1 year ago

I think it is definitely possible to do this within the scope of this project. From the technical aspect this is some work, but the difficulty is fairly easy. The hard part is to work out a syntax that is easy and intuitive to use. There would be the need to add a new bar on a specific display and a way to prefix commands that target this bar.

Once I have time to rework the popup system (which will bring most of the refactoring needed for this feature as well) I will think about this some more. If there are ideas for a full syntax (adding bars, removing bars, targeting bars) let me know.

The hackiest way to achieve this today is to have two or more distinct sketchybar binaries (with different binary names, bootstrap names, lock-files and sketchybarrc files) that operate completely independent of each other.

Another way to achieve this today is with popups, but it is not as flexible.

FelixKratz commented 1 year ago

Ok, so I have pondered with this idea for the last half an hour and have come up with something that is actually quite usable I think (https://github.com/FelixKratz/SketchyBar/commit/ff96bd76b84d9c4ade674f27153de91e32dd3659). The binary name of sketchybar can now be used as an identifier for multiple bars. I.e. if you install from HEAD (brew install sketchybar --head) you can:

ln -s /opt/homebrew/bin/sketchybar /opt/homebrew/bin/bottom_bar

and then run bottom_bar in your commandline. It will launch an additional bar which is targeted with bottom_bar --bar ... and has its config in ~/.config/bottom_bar/sketchybarrc. This is only an example but since the bars are entirely independent of each other it is possible to create as many bars as you like simply by symlinking as many bar instances as you like.

peterhajas commented 1 year ago

Thanks, @FelixKratz. This looks like a good way to explore multiple bars.

After copying my config and renaming the names of all my existing sketchybar invocations, I can now have two bars. Cool!

For syntax, I wonder if leaning on the existing --add semantics could work. So:

# add a bar
sketchybar --add bar my_bar

# change properties
sketchybar --bar my_bar set color=...

# add an item
sketchybar --bar my_bar --add item asdf

One thing that's missing with this approach (or the symlinked copy of sketchybar) is assigning a bar to a particular display. Happy to file another issue if you'd rather track that separately.

FelixKratz commented 1 year ago

Lets track the display options separately, it shouldnt be a problem to add more powerful display selectors.