SwiftBar icon indicating copy to clipboard operation
SwiftBar copied to clipboard

Add ENV variable containing plugin refresh trigger information

Open melonamin opened this issue 2 years ago • 2 comments

Plugin refresh can be triggered in many ways in SwiftBar, it would be useful to know the trigger during script execution.

melonamin avatar Jan 04 '24 14:01 melonamin

@stegmatze can you try this in beta build?

melonamin avatar Jan 04 '24 19:01 melonamin

@melonamin that was fast, thanks!

I was able to get it working together with refreshOnOpen=true. See this example script, executed every second for the time.

#!/bin/bash
#<swiftbar.refreshOnOpen>true</swiftbar.refreshOnOpen>

date +"%H:%M:%S"
echo "---"
if [ "$SWIFTBAR_PLUGIN_REFRESH_REASON" == "MenuOpen" ]
  then
    say "$SWIFTBAR_PLUGIN_REFRESH_REASON"
fi

This also works on the octoprint script mentioned in https://github.com/swiftbar/SwiftBar/discussions/403, but adds a ~1.5-second delay until the menu is open. Understandable, since the script is executed, image converted etc. Was hoping for it to be faster :-)

Overall, a useful addition!

stegmatze avatar Jan 05 '24 08:01 stegmatze