Add packaged plugin support (.swiftbar directories)#481
Merged
Conversation
Introduce PackagedPlugin, a new Plugin type that treats .swiftbar directories as self-contained plugin bundles with a plugin.* entry point and supporting files (libraries, assets, etc.). - Add PackagedPlugin.swift with full Plugin protocol conformance - Update PluginManager directory traversal to detect .swiftbar dirs and skip descending into their contents - Add workingDirectory parameter to runScript so packaged plugins execute with their package directory as cwd - Add SWIFTBAR_PLUGIN_PACKAGE_PATH environment variable - Register com.ameba.SwiftBar.PluginPackage UTI so Finder treats .swiftbar directories as opaque bundles
- Fix crash in enableTimer Combine sink (self! after weak self) - Fix disableTimer not invalidating cronTimer - Fix error shadowing in invoke() catch block - Make executable selection sort deterministic with alphabetical tie-breaking - Add logging when packaged plugin init fails in loadPlugin - Add plugin import support for .swiftbar packages via file open - Add sync path helpers for packaged plugin identity matching - Add tests for packaged plugin sync, merge, import, and validation
Extract `pluginNeverUpdateInterval` constant and `URL.isSwiftBarPackage` extension to eliminate scattered magic numbers and repeated string checks. Remove unused `fileManager` parameters from sync path helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #387
Adds support for packaged plugins —
.swiftbardirectories that bundle a main script with supporting files (libraries, assets, resources).PackagedPlugintype — fullPluginprotocol conformance with thread-safe metadata, timer lifecycle, and plugin variable supportPluginManagerdetects.swiftbardirectories as plugin bundles and skips descending into their contentscwd, so scripts can use relative paths (e.g.,source ./lib/utils.sh)SWIFTBAR_PLUGIN_PACKAGE_PATHis set to the package directory path.swiftbardirectories are registered ascom.ameba.SwiftBar.PluginPackageso Finder treats them as opaque bundlesPlugin structure
Ported from
This is a clean manual port of the
packaged_pluginsbranch onto currentmain, preserving all recent features (menu diffing, folding menus, plugin variables, stdin support) that would have been lost in a rebase.Test plan
.swiftbardirectory with aplugin.shentry point in the plugin folder — verify it loads and displays in the menu barsource ./lib/helper.shworks inside a packaged plugin (confirms working directory is set correctly)SWIFTBAR_PLUGIN_PACKAGE_PATHis set in the plugin's environment.swiftbardirectories appear as bundles in Finderplugin.30s.sh)