Skip to content

Commit 5852f7b

Browse files
committed
Background Security Update support
If there is only one update, check if it's a Background Security Update. Open Background Security Update prefpane when display name contains it.
1 parent e5a4a72 commit 5852f7b

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/Support/Views/UpdateView.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,19 @@ struct UpdateView: View {
7777
if computerinfo.recommendedUpdates.count > 0 {
7878

7979
Button(action: {
80-
openSoftwareUpdate()
80+
// If there is only one update, check if it's a Background Security Update
81+
if computerinfo.recommendedUpdates.count == 1 {
82+
if let update = computerinfo.recommendedUpdates.first {
83+
// Open Background Security Update prefpane when displayname contains it
84+
if update.displayName.contains("Background Security Improvement") {
85+
openBSI()
86+
} else {
87+
openSoftwareUpdate()
88+
}
89+
}
90+
} else {
91+
openSoftwareUpdate()
92+
}
8193
}) {
8294
Text(NSLocalizedString("UPDATE_NOW", comment: ""))
8395
.font(.system(.body, design: .rounded))
@@ -214,7 +226,7 @@ struct UpdateView: View {
214226
}
215227
}
216228

217-
// Open URL
229+
// Open Software Update prefpane in System Settings
218230
func openSoftwareUpdate() {
219231

220232
guard let url = URL(string: "x-apple.systempreferences:com.apple.preferences.softwareupdate") else {
@@ -227,6 +239,18 @@ struct UpdateView: View {
227239
appDelegate.togglePopover(nil)
228240

229241
}
242+
243+
// Open Software Update prefpane in System Settings
244+
func openBSI() {
245+
guard let url = URL(string: "x-apple.systempreferences:com.apple.SecurityImprovements-Settings.extension") else {
246+
return
247+
}
248+
249+
NSWorkspace.shared.open(url)
250+
251+
// Close popover
252+
appDelegate.togglePopover(nil)
253+
}
230254
}
231255

232256
struct UpdateViewLegacy: View {

0 commit comments

Comments
 (0)