diff --git a/aw_watcher_window/macos.swift b/aw_watcher_window/macos.swift index c1b25b46..b0dbac70 100644 --- a/aw_watcher_window/macos.swift +++ b/aw_watcher_window/macos.swift @@ -294,12 +294,21 @@ class MainThing { // calculate now before executing any scripting since that can take some time let nowTime = Date.now - var windowTitle: AnyObject? - AXUIElementCopyAttributeValue(axElement, kAXTitleAttribute as CFString, &windowTitle) + var rawWindowTitle: AnyObject? + AXUIElementCopyAttributeValue(axElement, kAXTitleAttribute as CFString, &rawWindowTitle) + let windowTitle: String = rawWindowTitle as? String ?? "" - var data = NetworkMessage(app: frontmost.localizedName!, title: windowTitle as? String ?? "") + let applicationTitle = frontmost.localizedName! - if CHROME_BROWSERS.contains(frontmost.localizedName!) { + // https://github.com/ActivityWatch/aw-watcher-window/issues/85 + guard applicationTitle != "loginwindow" && windowTitle != "Untitled" else { + log("loginwindow or Untitled detected, ignoring") + return + } + + var data = NetworkMessage(app: applicationTitle, title: windowTitle as? String ?? "") + + if CHROME_BROWSERS.contains(applicationTitle) { debug("Chrome browser detected, extracting URL and title") let chromeObject: ChromeProtocol = SBApplication.init(bundleIdentifier: bundleIdentifier)! @@ -323,7 +332,7 @@ class MainThing { } } } - } else if frontmost.localizedName == "Safari" { + } else if applicationTitle == "Safari" { debug("Safari browser detected, extracting URL and title") let safariObject: SafariApplication = SBApplication.init(bundleIdentifier: bundleIdentifier)!