Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore loginwindow events #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions aw_watcher_window/macos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand All @@ -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)!
Expand Down
Loading