swiftbar/SwiftBar

Add ENV variable containing plugin refresh trigger information

Opened this issue · 2 comments

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

@stegmatze can you try this in beta build?

@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 #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!