swiftbar/SwiftBar

Ephemeral Plugins

melonamin opened this issue · 5 comments

Problem

Currently, SwiftBar is great at:

  • Adding permanent menu bar item
  • Dynamically adding and hiding a menu bar item using StealthMode

SwiftBar is not great at showing transient menubar items. A basic example: you launch a long shell process and want to have an indication(red or green circle) in the menu bar when it finishes. Currently, there is no easy way to do this.

Solution

Add Ephemeral plugins, so you can tell SwiftBar to show a menubar item without adding a plugin.

Key features:

  • can be created\updated\deleted through URL Scheme, Shortcuts and CLI(TBD if this is to much of a hustle)
  • Full support of SwiftBar plugin syntax
  • Can be removed from the menu bar using a special menu item specific to this type of plugin
  • all ephemeral plugins disappear on SwiftBar restart
  • ephemeral plugin can have a lifetime, i.e. self remove after 20 minutes

Love this idea. I think the key is going to be the ability for them to be unique, and addressable. So either the scripter would need to assign them a name, or SwiftBar would need to assign them an ID of some kind that's returned as output. That way, I can keep updating my status item as it moves through the process.

So is there documentation somewhere on how to make an ephemeral plugin?

One of the reasons it is still in beta - I didn't have time to write the docs 😭

It is pretty easy to use, you have 3 parameters

  • name - this is the plugin name, should be unique
  • content - this is the markup you want SwiftBar to render
  • exitafter - this is optional parameter forces plugin to exit after a period of time, set in seconds.. Defaults to 0, which means don't exit :)

You can use it with URL scheme: swiftbar://setephemeralplugin?name=...content=... or thorugh new Shorctuts action "Set Ephemeral Plugin"

@jasonsnell have you had a chance to try it yet?

Yep! Added it to my loooong transcription shortcut and it seems to have worked?