swiftbar / SwiftBar

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

Plugin with multiple files #387

Open olfway opened 1 year ago

olfway commented 1 year ago

What would be easier if plugin can be a macos bundle / simple folder / zip file with multiple files and resources instead of single file

Similar request in xbar: https://github.com/matryer/xbar/issues/791

dchevell commented 1 year ago

358 would effectively address this, and I think in a simpler/more flexible way. Imagine:

<swiftbar plugin folder>/MyPlugin/
<swiftbar plugin folder>/MyPlugin/myscript.sh
<swiftbar plugin folder>/MyPlugin/.swiftbarignore
<swiftbar plugin folder>/MyPlugin/core/<a bunch of files>
<swiftbar plugin folder>/MyPlugin/lib/<a bunch of files>

Your .swiftbarignore file would just contain some entries like core/* and lib/*, and SwiftBar itself would run your "entrypoint" script and ignore everything else.

melonamin commented 1 year ago

I've been thinking about plugin bundles for a while, but not sure that the upsides are bigger than additional complexity.

And I think @dchevell is right, the #358 along with built in support for per plugin CACHE\DATA folders (#200) should be enough.

But I'm open to suggestions, if @olfway you can build a case for adding the bundles.

olfway commented 1 year ago

My idea was to split icon resources and maybe some helper scripts out of main script. So, it's seems it's already possible with .swiftbarignore, thanks @dchevell!

But as far as I understand it's not possible now to install this "multi-files" plugins with swiftbar's plugins repository manager, right?

melonamin commented 1 year ago

it's not possible now to install this "multi-files" plugins with swiftbar's plugins repository manager,

Yeah, thats correct. I guess it could be added as zip, which SwiftBar will automatically extract.

olfway commented 1 year ago

I wonder if it's possible to somehow add it as directory to repo but then download it as zip?

Actually, there is an api to get list of files and folders for any path, for example: https://api.github.com/repositories/49141197/contents/Cloud

melonamin commented 1 year ago

The problem is that Plugin Repository is based on xbar.com and to make this happen we would need to implement this change on their end, which is probably not going to happen(the project in light maintenance mode).

Adding this feature only for custom Plugin Repositories would be a too narrow use case(?).

SwiftBar can install plugins directly from URL, maybe I can add this feature there, but it will be exclusivly for GitHub.

peanball commented 1 year ago

you could always append the zip file to the end of your script and unzip it "from the end of the script" into the SWIFTBAR provided temp folder.

Some guides on the idea: https://www.linuxjournal.com/node/1005818

I'm sure you can adapt figuring out how to make it use the right path for the tar.gz extraction, as provided by the plugin-specific env variable.