mirror of
https://github.com/swiftbar/SwiftBar.git
synced 2024-10-27 00:50:16 +03:00
Fix PR feedback
This commit is contained in:
parent
ce65ea4154
commit
970f0d83af
@ -226,7 +226,7 @@ For binary plugins metadata can be added as an extended file attribute:
|
||||
| refreshplugin | `name` plugin [name](#plugin-naming) | Force refresh plugin by name | `swiftbar://refreshplugin?name=myplugin` |
|
||||
| refreshplugin | `index` plugin index in menubar, starting from `0` | Force refresh plugin by its position in menubar | `swiftbar://refreshplugin?index=1` |
|
||||
| addplugin | `src` source URL to plugin file | Add plugin to Swiftbar from URL | `swiftbar://addplugin?src=https://coolplugin` |
|
||||
| notify | `plugin` plugin [name](#plugin-naming). Notification fields: `title`, `subtitle`, `body`. `open` to open an URL on click. `silent=true` to disable sound | Show notification | `swiftbar://notify?plugin=MyPlugin&title=title&subtitle=subtitle&body=body&silent=true` |
|
||||
| notify | `plugin` plugin [name](#plugin-naming). Notification fields: `title`, `subtitle`, `body`. `href` to open an URL on click (including custom URL schemes). `silent=true` to disable sound | Show notification | `swiftbar://notify?plugin=MyPlugin&title=title&subtitle=subtitle&body=body&silent=true` |
|
||||
|
||||
## Preferences aka 'defaults'
|
||||
|
||||
|
@ -125,7 +125,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, SPUStandardUserDriverDelegat
|
||||
title: url.queryParameters?["title"],
|
||||
subtitle: url.queryParameters?["subtitle"],
|
||||
body: url.queryParameters?["body"],
|
||||
open: url.queryParameters?["open"],
|
||||
href: url.queryParameters?["href"],
|
||||
silent: url.queryParameters?["silent"] == "true")
|
||||
default:
|
||||
os_log("Unsupported URL scheme \n %{public}@", log: Log.plugin, type: .error, url.absoluteString)
|
||||
@ -134,10 +134,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, SPUStandardUserDriverDelegat
|
||||
}
|
||||
|
||||
func userNotificationCenter(_: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
let urlString = response.notification.request.content.userInfo["url"] as? String ?? ""
|
||||
|
||||
if urlString != "" {
|
||||
let url = URL(string: urlString)!
|
||||
if let urlString = response.notification.request.content.userInfo["url"] as? String,
|
||||
let url = URL(string: urlString)
|
||||
{
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ class PluginManager {
|
||||
}
|
||||
|
||||
extension PluginManager {
|
||||
func showNotification(pluginID: PluginID, title: String?, subtitle: String?, body: String?, open: String?, silent: Bool = false) {
|
||||
func showNotification(pluginID: PluginID, title: String?, subtitle: String?, body: String?, href: String?, silent: Bool = false) {
|
||||
guard let plugin = plugins.first(where: { $0.id == pluginID }),
|
||||
plugin.enabled else { return }
|
||||
|
||||
@ -249,10 +249,9 @@ extension PluginManager {
|
||||
content.sound = silent ? nil : .default
|
||||
content.threadIdentifier = pluginID
|
||||
|
||||
let urlString = open ?? ""
|
||||
let url = URL(string: urlString)
|
||||
|
||||
if url?.host != nil, url?.scheme != nil {
|
||||
if let urlString = href,
|
||||
let url = URL(string: urlString), url.host != nil, url.scheme != nil
|
||||
{
|
||||
content.userInfo = ["url": urlString]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user