swiftbar / SwiftBar

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

Menu does not open when shell action is attached to menu title #356

Closed dchevell closed 1 year ago

dchevell commented 1 year ago

Describe the bug If the menu title (i.e. above the ---) has an action attached (shell=..., bash=..., href=...) the action runs when the menu is clicked, but the menu doesn't open.

To Reproduce Steps to reproduce the behavior:

  1. Create the following script:
    echo "test menu | shell=open param0=/System/Applications/TextEdit.app terminal=False"
    echo "---"
    echo "menu option"
  2. Click on the menu title. TextEdit opens, but the menu doesn't. (Right clicking on the menu can get it to open)

Expected behavior The command runs (i.e. TextEdit opens), and the menu opens

Environment:

Plugin Example:

echo "test menu | shell=open param0=/System/Applications/TextEdit.app terminal=False"
echo "---"
echo "menu option"
melonamin commented 1 year ago

Hi @dchevell. This is by design, if you assign an action - only the action runs, nothing else. This is more sensible default in my mind, then running the action AND opening the menu at the same time

As you noted, right click or option+left click opens the menu every time.

dchevell commented 1 year ago

Got it. That's a shame - my use case is essentially putting notifications into the menu with an unread badge, and then marking them as read when I open the menu. The current behaviour only allows one or the other - mark them as read without reading them, or read them without marking them as read.

Is there any workaround?

melonamin commented 1 year ago

I would probably add additional menu item “Mark All as Read” - extra click, but does the job. Additionally opens an opportunity to keep the notifications unread.

Feature wise, potentially I can add a defaults option for changing the default behavior to what you want. Probably you would be the only one to use it :)

dchevell commented 1 year ago

Probably you would be the only one to use it :)

The perils of maintaining software, never a good idea to add complexity if you can avoid it 😂

Yeah, I thought about just adding a manual "clear" button. The other option I considered was clearing it only when clicking on one of the items (they open URL's) but it looks like you can't combine shell and href into the same menu action either, and beyond that we're getting into pretty hacky territory.

I'm not 100% sure I agree that action vs opening the menu is expected behaviour, but I understand where you're coming from. You can close this out.

melonamin commented 1 year ago

but it looks like you can't combine shell and href into the same menu action either

Correct, only one action is processed, all other are ignored. You can use shell and add open href into your plugin script.