-
-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move scripts/clean-launch-services-database to tools/clean-launch-ser…
…vices-database
- Loading branch information
Showing
8 changed files
with
76 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
all: | ||
swift run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// swift-tools-version: 5.5 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "clean-launch-services-database", | ||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.executableTarget( | ||
name: "clean-launch-services-database"), | ||
] | ||
) |
14 changes: 14 additions & 0 deletions
14
tools/clean-launch-services-database/Sources/clean-launch-services-database/config.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
let bundleIdentifiers = [ | ||
// Karabiner-Elements | ||
"org.pqrs.Karabiner-EventViewer", | ||
"org.pqrs.Karabiner-Menu", | ||
"org.pqrs.Karabiner-MultitouchExtension", | ||
"org.pqrs.Karabiner-NotificationWindow", | ||
"org.pqrs.Karabiner-Elements.Settings", | ||
|
||
// Karabiner-DriverKit-VirtualHIDDevice | ||
"org.pqrs.HIDManagerTool", | ||
"org.pqrs.Karabiner-DriverKit-VirtualHIDDeviceClient", | ||
"org.pqrs.Karabiner-VirtualHIDDevice-Manager", | ||
"org.pqrs.virtual-hid-device-service-client", | ||
] |
44 changes: 44 additions & 0 deletions
44
tools/clean-launch-services-database/Sources/clean-launch-services-database/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import AppKit | ||
|
||
// | ||
// The built application is automatically registered in the Launch Services database. | ||
// This means that unwanted entries such as */build/Release/*.app will be registered. | ||
// | ||
// Then, the names displayed in Background items of Login Items System Settings refer to the launch services database. | ||
// If the path of the built application is referenced, the application name may not be taken properly and the developer name may appear in Login Items. | ||
// | ||
// To avoid this problem, unintended application entries should be removed from the database. | ||
// This script removes such entries which includes /Build/ or /build/ in the file path. | ||
// | ||
|
||
if #available(macOS 13.0, *) { | ||
let lsregisterCommandPath = | ||
"/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister" | ||
let deleteTargetPathRegex = #/ | ||
/build/ | | ||
/Build/ | ||
/# | ||
|
||
for bundleIdentifier in bundleIdentifiers { | ||
print("clean-launch-services-database \(bundleIdentifier)...") | ||
|
||
let urls = NSWorkspace.shared.urlsForApplications(withBundleIdentifier: bundleIdentifier) | ||
|
||
for url in urls { | ||
let path = url.path | ||
if path.matches(of: deleteTargetPathRegex).count > 0 { | ||
print("unregister from the Launch Services database: \(path)") | ||
|
||
let process = Process() | ||
process.launchPath = lsregisterCommandPath | ||
process.arguments = [ | ||
"-u", | ||
path, | ||
] | ||
|
||
process.launch() | ||
process.waitUntilExit() | ||
} | ||
} | ||
} | ||
} |