Skip to content

Commit 5b80332

Browse files
committed
fix: ignore loginwindow events
workaround for ActivityWatch#85
1 parent 73ca1fc commit 5b80332

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

aw_watcher_window/macos.swift

+11-3
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,17 @@ class MainThing {
297297
var windowTitle: AnyObject?
298298
AXUIElementCopyAttributeValue(axElement, kAXTitleAttribute as CFString, &windowTitle)
299299

300-
var data = NetworkMessage(app: frontmost.localizedName!, title: windowTitle as? String ?? "")
300+
let applicationTitle = frontmost.localizedName!
301301

302-
if CHROME_BROWSERS.contains(frontmost.localizedName!) {
302+
// https://github.com/ActivityWatch/aw-watcher-window/issues/85
303+
guard applicationTitle != "loginwindow" else {
304+
log("loginwindow detected, ignoring")
305+
return
306+
}
307+
308+
var data = NetworkMessage(app: applicationTitle, title: windowTitle as? String ?? "")
309+
310+
if CHROME_BROWSERS.contains(applicationTitle) {
303311
debug("Chrome browser detected, extracting URL and title")
304312

305313
let chromeObject: ChromeProtocol = SBApplication.init(bundleIdentifier: bundleIdentifier)!
@@ -323,7 +331,7 @@ class MainThing {
323331
}
324332
}
325333
}
326-
} else if frontmost.localizedName == "Safari" {
334+
} else if applicationTitle == "Safari" {
327335
debug("Safari browser detected, extracting URL and title")
328336

329337
let safariObject: SafariApplication = SBApplication.init(bundleIdentifier: bundleIdentifier)!

0 commit comments

Comments
 (0)