mirror of
https://github.com/swiftbar/SwiftBar.git
synced 2024-10-03 19:17:43 +03:00
Add plugin refresh reason to ENV #404
Signed-off-by: Alex Mazanov <alexandr.mazanov@gmail.com>
This commit is contained in:
parent
3e93034c49
commit
28ef89ff82
@ -176,6 +176,7 @@ When running a plugin, SwiftBar sets the following environment variables:
|
||||
| `SWIFTBAR_PLUGIN_PATH` | The path to the running plugin |
|
||||
| `SWIFTBAR_PLUGIN_CACHE_PATH` | The cache to data folder, individual per plugin |
|
||||
| `SWIFTBAR_PLUGIN_DATA_PATH` | The path to data folder, individual per plugin |
|
||||
| `SWIFTBAR_PLUGIN_REFRESH_REASON` | Plugin refresh reason\trigger |
|
||||
| `SWIFTBAR_LAUNCH_TIME` | SwiftBar launch date and time, ISO8601 |
|
||||
| `OS_APPEARANCE` | Current macOS appearance (`Light` or `Dark`) |
|
||||
| `OS_VERSION_MAJOR` | The first part of the macOS version (e.g., `11` for macOS 11.0.1) |
|
||||
|
@ -702,6 +702,7 @@ extension MenubarItem {
|
||||
|
||||
func refreshAndShowMenu() {
|
||||
os_log("Refreshing for refreshOnOpen plugin", log: Log.plugin, type: .info)
|
||||
plugin?.lastRefreshReason = .MenuOpen
|
||||
let content = plugin?.invoke()
|
||||
_updateMenu(content: content)
|
||||
barItem.menu = statusBarMenu
|
||||
|
@ -29,7 +29,7 @@ enum PluginState {
|
||||
case Disabled
|
||||
}
|
||||
|
||||
enum PluginRefreshReason {
|
||||
enum PluginRefreshReason: String {
|
||||
case FirstLaunch
|
||||
case Schedule
|
||||
case MenuAction
|
||||
@ -40,6 +40,7 @@ enum PluginRefreshReason {
|
||||
case DebugView
|
||||
case NotificationAction
|
||||
case PluginSettings
|
||||
case MenuOpen
|
||||
|
||||
static func manualReasons() -> [Self] {
|
||||
[
|
||||
@ -51,6 +52,7 @@ enum PluginRefreshReason {
|
||||
.NotificationAction,
|
||||
.PluginSettings,
|
||||
.DebugView,
|
||||
.MenuOpen,
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -148,6 +150,7 @@ extension Plugin {
|
||||
Environment.Variables.osAppearance.rawValue: AppShared.isDarkTheme ? "Dark" : "Light",
|
||||
Environment.Variables.swiftBarPluginCachePath.rawValue: cacheDirectoryPath,
|
||||
Environment.Variables.swiftBarPluginDataPath.rawValue: dataDirectoryPath,
|
||||
Environment.Variables.swiftBarPluginRefreshReason.rawValue: lastRefreshReason.rawValue,
|
||||
]
|
||||
metadata?.environment.forEach { k, v in
|
||||
pluginEnv[k] = v
|
||||
|
@ -11,6 +11,7 @@ class Environment {
|
||||
case swiftBarPluginPath = "SWIFTBAR_PLUGIN_PATH"
|
||||
case swiftBarPluginCachePath = "SWIFTBAR_PLUGIN_CACHE_PATH"
|
||||
case swiftBarPluginDataPath = "SWIFTBAR_PLUGIN_DATA_PATH"
|
||||
case swiftBarPluginRefreshReason = "SWIFTBAR_PLUGIN_REFRESH_REASON"
|
||||
case swiftBarLaunchTime = "SWIFTBAR_LAUNCH_TIME"
|
||||
case osVersionMajor = "OS_VERSION_MAJOR"
|
||||
case osVersionMinor = "OS_VERSION_MINOR"
|
||||
|
Loading…
Reference in New Issue
Block a user