diff --git a/README.md b/README.md
index 1234108..2610ba1 100644
--- a/README.md
+++ b/README.md
@@ -211,7 +211,7 @@ A special tag can be used as an alternative to refresh interval defined in plugi
* `false` - doesn't wrap plugins in Bash when running
* `streamable` - mark plugin as Streamable
-* `['var1':'default value', 'var2':'default value', ... ]` - this variables will be passed in plugin's environment, in later release SwiftBar will provide a UI to change values for these variables.
+* `[var1:default value, var2:default value, ... ]` - this variables will be passed in plugin's environment, in later release SwiftBar will provide a UI to change values for these variables.
#### Metadata for Binary Plugins
diff --git a/SwiftBar/Plugin/Plugin.swift b/SwiftBar/Plugin/Plugin.swift
index f9ac32a..4a90ec4 100644
--- a/SwiftBar/Plugin/Plugin.swift
+++ b/SwiftBar/Plugin/Plugin.swift
@@ -100,11 +100,15 @@ extension Plugin {
}
var env: [String: String] {
- [
+ var pluginEnv = [
EnvironmentVariables.swiftBarPluginPath.rawValue: file,
EnvironmentVariables.osAppearance.rawValue: AppShared.isDarkTheme ? "Dark" : "Light",
EnvironmentVariables.swiftBarPluginCachePath.rawValue: cacheDirectoryPath,
EnvironmentVariables.swiftBarPluginDataPath.rawValue: dataDirectoryPath,
]
+ metadata?.environment.forEach { k, v in
+ pluginEnv[k] = v
+ }
+ return pluginEnv
}
}
diff --git a/SwiftBar/Plugin/PluginMetadata.swift b/SwiftBar/Plugin/PluginMetadata.swift
index 37ecc2b..1175b5a 100644
--- a/SwiftBar/Plugin/PluginMetadata.swift
+++ b/SwiftBar/Plugin/PluginMetadata.swift
@@ -122,11 +122,14 @@ class PluginMetadata: ObservableObject {
}
var environment: [String: String] = [:]
if !getTagValue(tag: .environment).isEmpty {
- getTagValue(tag: .environment).split(separator: ",").forEach { str in
- let pair = str.split(separator: ":").map { $0.trimmingCharacters(in: .whitespaces) }
- guard pair.count == 2 else { return }
- environment[pair[0]] = pair[1]
- }
+ getTagValue(tag: .environment)
+ .dropFirst()
+ .dropLast()
+ .split(separator: ",").forEach { str in
+ let pair = str.split(separator: ":").map { $0.trimmingCharacters(in: .whitespaces) }
+ guard pair.count == 2 else { return }
+ environment[pair[0]] = pair[1]
+ }
}
return PluginMetadata(name: getTagValue(tag: .title),