mirror of
https://github.com/swiftbar/SwiftBar.git
synced 2024-08-17 12:00:27 +03:00
Fixing swiftbar.environment not available #214
This commit is contained in:
parent
d965521b82
commit
e5403402aa
@ -211,7 +211,7 @@ A special tag can be used as an alternative to refresh interval defined in plugi
|
||||
|
||||
* `<swiftbar.runInBash>false</swiftbar.runInBash>` - doesn't wrap plugins in Bash when running
|
||||
* `<swiftbar.type>streamable</swiftbar.type>` - mark plugin as Streamable
|
||||
* `<swiftbar.environment>['var1':'default value', 'var2':'default value', ... ]</swiftbar.environment>` - this variables will be passed in plugin's environment, in later release SwiftBar will provide a UI to change values for these variables.
|
||||
* `<swiftbar.environment>[var1:default value, var2:default value, ... ]</swiftbar.environment>` - 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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user