Skip to content

Commit

Permalink
Merge pull request #28 from ShlomoCode/clean-get-bundle-url
Browse files Browse the repository at this point in the history
Refactor: get bundle url directly using NSWorkspace.shared.urlForApplication
  • Loading branch information
ejbills authored Jun 26, 2024
2 parents 3fb6a84 + 6eed7be commit dbdbf9c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions DockDoor/Utilities/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ struct WindowUtil {

/// Retrieves the active windows for a given application name.
static func activeWindows(for applicationName: String) async throws -> [WindowInfo] {
func getNonLocalizedAppName(for app: NSRunningApplication) -> String? {
guard let bundleURL = app.bundleURL else {
func getNonLocalizedAppName(forBundleIdentifier bundleIdentifier: String) -> String? {
guard let bundleURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleIdentifier) else {
return nil
}

Expand All @@ -265,8 +265,7 @@ struct WindowUtil {

for window in content.windows {
if let app = window.owningApplication,
let tempApp = NSRunningApplication.runningApplications(withBundleIdentifier: app.bundleIdentifier).first,
let nonLocalName = getNonLocalizedAppName(for: tempApp){
let nonLocalName = getNonLocalizedAppName(forBundleIdentifier: app.bundleIdentifier) {

// Collect potential matches
if applicationName.contains(app.applicationName) || app.applicationName.contains(applicationName) {
Expand Down

0 comments on commit dbdbf9c

Please sign in to comment.