-
-
Notifications
You must be signed in to change notification settings - Fork 109
Description
Hello, thank you very much for this wonderful app. I’m currently trying to use it to implement things I’ve wanted to build for a long time.
While doing so, I noticed that a script doesn’t seem to refresh when an href is specified and the website is opened.
Is this the intended behavior, or am I doing something wrong?
I’d like to trigger an action with the script while still opening the URL.
Example:
#!/bin/bash
echo "Test"
echo "---"
echo "**refreh with href doesnt work** | md=true refresh=true href=https://url.com"
echo "**refreh without href does work** | md=true refresh=true"
UPDATE:
After a bit of research, it seems that this function returns after the first successful action without checking the remaining actions.
Is this intended behavior?
For my use case, it would be great if all actions could be executed. However, I don’t know whether that would have any unintended side effects.
SwiftBar/SwiftBar/MenuBar/MenuBarItem.swift
Lines 822 to 899 in 16388f6
| @discardableResult func performItemAction(params: MenuLineParameters) -> Bool { | |
| var out = false | |
| defer { | |
| if params.color != nil, out { | |
| updateMenu(content: plugin?.content) // dumb fix for #221, ideally come up with something better... | |
| } | |
| } | |
| if let url = params.href?.getURL(), url.absoluteString != "." { | |
| if params.webView { | |
| showWebPopover( | |
| url: url, | |
| widht: params.webViewWidth, | |
| height: params.webViewHeight, | |
| zoom: params.webViewZoom | |
| ) | |
| } else { | |
| NSWorkspace.shared.open(url) | |
| } | |
| out = true | |
| return out | |
| } | |
| if let bash = params.bash { | |
| AppShared.runInTerminal(script: bash, args: params.bashParams, runInBackground: !params.terminal, | |
| env: plugin?.env ?? [:], runInBash: plugin?.metadata?.shouldRunInBash ?? true) | |
| { [weak self] in | |
| if params.refresh { | |
| self?.plugin?.refresh(reason: .MenuAction) | |
| } | |
| } | |
| out = true | |
| return out | |
| } | |
| if let stdinInput = params.stdin { | |
| guard let plugin else { | |
| os_log("No plugin available to handle stdin input", log: Log.plugin, type: .error) | |
| return out | |
| } | |
| do { | |
| try plugin.writeStdin(stdinInput) | |
| if params.refresh { | |
| plugin.refresh(reason: .MenuAction) | |
| } | |
| out = true | |
| } catch { | |
| plugin.error = error | |
| os_log("Failed to write stdin for plugin %{public}@: %{public}@", log: Log.plugin, type: .error, plugin.name, error.localizedDescription) | |
| DispatchQueue.main.async { [weak self] in | |
| guard let self, !self.isOpen else { return } | |
| self.showErrorPopover() | |
| } | |
| } | |
| return out | |
| } | |
| if params.refresh { | |
| dimOnManualRefresh() | |
| plugin?.refresh(reason: .MenuAction) | |
| out = true | |
| return out | |
| } | |
| out = false | |
| return out | |
| } | |
| @objc func perfomMenutItemAction(_ sender: NSMenuItem) { | |
| guard let params = sender.representedObject as? MenuLineParameters else { return } | |
| performItemAction(params: params) | |
| } | |
| } |