swiftbar / SwiftBar

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

`font=` parameter disallow execution #306

Closed kdeldycke closed 2 years ago

kdeldycke commented 2 years ago

Describe the bug

It seems that an entry in a sub-menu is not allowed to be clicked and is greyed out each time a font-related option (like font= or emojize=) is used.

To Reproduce

Here is a simple script printing a string:

#!/usr/bin/env python3

print(
"""↑4 | dropdown=false
---
Homebrew Formulae: 3 packages | font=Menlo | emojize=false
--broot     1.11.0 → 1.11.1 | refresh=true | shell=/opt/homebrew/bin/brew | param1=upgrade | param2=broot | param3=--formula | terminal=true
-----
--Upgrade all | shell=/opt/homebrew/bin/brew | param1=upgrade | param2=None | param3=--formula | font=Menlo | refresh=true | terminal=false
""")

This renders as:

Screen Shot 2022-04-06 at 17 02 31

Now if I change that script to (notice the addition of | font=Menlo | to the broot line):

#!/usr/bin/env python3

print(
"""↑4 | dropdown=false
---
Homebrew Formulae: 3 packages | font=Menlo | emojize=false
--broot     1.11.0 → 1.11.1 | font=Menlo | refresh=true | shell=/opt/homebrew/bin/brew | param1=upgrade | param2=broot | param3=--formula | terminal=true
-----
--Upgrade all | shell=/opt/homebrew/bin/brew | param1=upgrade | param2=None | param3=--formula | font=Menlo | refresh=true | terminal=false
""")

It renders as:

Screen Shot 2022-04-06 at 17 10 39

You can notice how the submenu item is disabled and greyed-out.

Instead, I expect it to be enabled.

Environment:

Plugin Example: This issue has been simplified but was encountered with the latest version (v4.12.1) of the meta_package_manager.7h.py plugin.

melonamin commented 2 years ago

Hey @kdeldycke

You are using the following syntax: <Item Title> | param = ... | param = ... | param = .... Where is it coming from?

Per Readme <Item Title> | [param = ...], where:

And your simplified example should look like this:

print(
    """↑4 | dropdown=false
---
Homebrew Formulae: 3 packages | font=Menlo emojize=false
--broot     1.11.0 → 1.11.1 | font=Menlo  refresh=true  shell=/opt/homebrew/bin/brew  param1=upgrade  param2=broot  param3=--formula  terminal=true
-----
--Upgrade all | shell=/opt/homebrew/bin/brew  param1=upgrade  param2=None  param3=--formula  font=Menlo  refresh=true  terminal=false
"""
)

I hope it helps.

kdeldycke commented 2 years ago

Oh I see. <Item Title> | param = ... | param = ... | param = ... is from the bitbar/xbar specifications.

I'll try to have my script works for both xbar and SwiftBar them. Thanks for the tip and sorry for the noise! 😅

melonamin commented 2 years ago

bitbar/xbar specifications

I don't believe that Bitbar ever behaved like this, I re-implemented the specification 1-to-1. Looks like it was added as a part of xbar evolution, I have no idea why...

I'll try to have my script works for both xbar and SwiftBar them

I suggest you to try the SwiftBar\bitbar syntax first and see if it works in xbar.

kdeldycke commented 2 years ago

I don't believe that Bitbar ever behaved like this, I re-implemented the specification 1-to-1. Looks like it was added as a part of xbar evolution, I have no idea why...

Indeed, this seems like a recent addition. Still, you're right: the pipe separator is supported but optional. I guess we'll see more of these pipe-separated parameters from the plugin repository now that the cat is out of the bag.

As for the reason this was added, maybe it is to make the parser more robust. I might even have encountered some edge-cases, but need to experiment more on my side.