Skip to content

Commit

Permalink
Add support for Linear
Browse files Browse the repository at this point in the history
  • Loading branch information
starbugs committed Mar 20, 2024
1 parent a6ec69b commit c126c7d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
18 changes: 18 additions & 0 deletions WakaTime/Extensions/AXUIElementExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ extension AXUIElement {
// swiftlint:enable force_cast
}

var nextSibling: AXUIElement? {
guard let parentChildren = self.parent?.children, let currentIndex = parentChildren.firstIndex(of: self) else { return nil }
let nextIndex = currentIndex + 1
guard parentChildren.indices.contains(nextIndex) else { return nil }
return parentChildren[nextIndex]
}

var previousSibling: AXUIElement? {
guard let parentChildren = self.parent?.children, let currentIndex = parentChildren.firstIndex(of: self) else { return nil }
let previousIndex = currentIndex - 1
guard parentChildren.indices.contains(previousIndex) else { return nil }
return parentChildren[previousIndex]
}

var id: String? {
guard let ref = getValue(for: kAXIdentifierAttribute) else { return nil }
// swiftlint:disable force_cast
Expand Down Expand Up @@ -72,6 +86,10 @@ extension AXUIElement {
case .firefox:
let addressField = findAddressField()
address = addressField?.value
case .linear:
let projectLabel = firstDescendantWhere { $0.value == "Project" }
let projectButton = projectLabel?.nextSibling?.firstDescendantWhere { $0.role == kAXButtonRole }
return projectButton?.rawTitle
case .safari:
let addressField = elementById(identifier: "WEB_BROWSER_ADDRESS_AND_SEARCH_FIELD")
address = addressField?.value
Expand Down
4 changes: 1 addition & 3 deletions WakaTime/Extensions/NSRunningApplicationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ enum MonitoredApp: String, CaseIterable {
]

// list apps which we aren't yet able to track, so they're hidden from the Monitored Apps menu
static let unsupportedAppIds = [
MonitoredApp.linear.rawValue,
]
static let unsupportedAppIds = [String]()
}

extension NSRunningApplication {
Expand Down
1 change: 1 addition & 0 deletions WakaTime/Helpers/MonitoringManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class MonitoringManager {
case .linear:
return HeartbeatData(
entity: title,
project: project,
category: .planning)
case .notes:
if activeWindow.rawTitle == "Notes" {
Expand Down

0 comments on commit c126c7d

Please sign in to comment.