Add ENV variable containing plugin refresh trigger information
Opened this issue · 2 comments
melonamin commented
Plugin refresh can be triggered in many ways in SwiftBar, it would be useful to know the trigger during script execution.
melonamin commented
@stegmatze can you try this in beta build?
stegmatze commented
@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!