Skip to content

Commit

Permalink
Used bundleIdentifier instead of localizedName (#7)
Browse files Browse the repository at this point in the history
* use bundleIdentifier instead of localizedName

* use bundleIdentifier instead of localizedName

Co-authored-by: Lilla Baldovini <[email protected]>
  • Loading branch information
lillabldv and Lilla Baldovini authored Dec 8, 2020
1 parent 33251af commit 9c33b06
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions noTunes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let runningApp = apps[currentApp.offset]

if(runningApp.activationPolicy == .regular) {
if(runningApp.localizedName == "iTunes") {
if(runningApp.bundleIdentifier == "com.apple.itunes") {
self.terminateProcessWith(Int(runningApp.processIdentifier), runningApp.localizedName!)
}
if(runningApp.localizedName == "Music") {
if(runningApp.bundleIdentifier == "com.apple.Music") {
self.terminateProcessWith(Int(runningApp.processIdentifier), runningApp.localizedName!)
}
}
Expand All @@ -72,12 +72,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {

@objc func appWillLaunch(note:Notification) {
if statusItem.image == NSImage(named: "StatusBarButtonImageActive") {
if let processName:String = note.userInfo?["NSApplicationName"] as? String {
if let processName:String = note.userInfo?["NSApplicationBundleIdentifier"] as? String {
if let processId = note.userInfo?["NSApplicationProcessIdentifier"] as? Int {
switch processName {
case "iTunes":
case "com.apple.itunes":
self.terminateProcessWith(processId, processName)
case "Music":
case "com.apple.Music":
self.terminateProcessWith(processId, processName)
default:break
}
Expand Down

0 comments on commit 9c33b06

Please sign in to comment.