swiftbar / SwiftBar

Powerful macOS menu bar customization tool
https://swiftbar.app
MIT License
2.93k stars 92 forks source link

sfimage parameter is not effected by sfcolor #364

Closed bringel closed 1 year ago

bringel commented 1 year ago

Describe the bug While working on a plugin, was using the sfimage and sfcolor parameters on my output expecting the color to change. This did not work until I changed to using the :sfsymbol.name.here: syntax in the text part of the output.

To Reproduce Steps to reproduce the behavior:

  1. ...

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

Plugin Example: Sample plugin to reproduce the issue, link or code.

Additional Context:

dchevell commented 1 year ago

I believe this would be a breaking change for existing plugins - right now sfcolor sets the colour of inline symbols in the menu item text. Making this change would mean existing plugin scripts that already use sfcolor for inline symbols, and which also use sfimage, would end up with weird / unwanted colours set for sfimage.

It's worth figuring out how to enable this, just calling out that it might not be so simple.

smammy commented 1 year ago

Personally I'd be more worried about having a confusing/overly-complicated API than backwards-compatibility: the plugin ecosystem is small and plugins are easily hackable.

But if this is a concern, adding an sfimagecolor parameter would make sense to me.

dchevell commented 1 year ago

It's not just that - this would effectively link two unrelated symbols to the one colour directive, so something would have to change either way. One alternative I can think of would be to simply consider sfimage when counting the indexes for sfcolor, so if sfimage is present then it's considered to be at index 0, and inline symbols would then start from 1.

For reference, I was testing a beta build for an unrelated issue and found that multiple scripts of mine were all broken with random icon colours, now I know it was this change being tested :)

smammy commented 1 year ago

Ah, gotcha. Assigning the sfimage index 0 in the sfcolor list (would that be sfcolor0?) would work.

Not sure if there's precedent for this, but what about extending the format of sfimage so that it could take colors as extra parameters? For example: sfimage=exclamationmark.triangle,#ffe000,#ffffcc This could keep the color information "closer" to the symbol name, which might be nice.

peanball commented 1 year ago

It's already merged: https://github.com/swiftbar/SwiftBar/pull/370

And yes, there are still some edge cases. This format takes the color for the first SF color. If you had an sfimage and inline icons, the color of the sfimage and the first sficon would be the same.

dchevell commented 1 year ago

Is there a workaround for the concern I raised above? My scripts that use sfimage and inline icons now share a colour that was only intended for the inline icon. Indexing all available icons from 0 (starting with sfimage) or something would help