Skip to content

Commit

Permalink
Merge pull request #176 from GetPerspectdev/feature/imessage-and-more…
Browse files Browse the repository at this point in the history
…-apps

Feature/imessage and more apps
  • Loading branch information
alanhamlett authored Nov 29, 2023
2 parents 92c6fc9 + 82271d6 commit 605c910
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 27 deletions.
86 changes: 61 additions & 25 deletions WakaTime/Extensions/AXUIElementExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,67 @@ extension AXUIElement {

func title(for app: MonitoredApp) -> String? {
switch app {
case .figma:
guard
let title = extractPrefix(rawTitle, separator: ""),
title != "Figma",
title != "Drafts"
else { return nil }

return title
case .postman:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Postman"
else { return nil }

return title
case .canva:
guard
let title = extractPrefix(rawTitle, separator: " - ", minCount: 2),
title != "Canva",
title != "Home"
else { return nil }

return title
case .xcode:
return nil
case .figma:
guard
let title = extractPrefix(rawTitle, separator: ""),
title != "Figma",
title != "Drafts"
else { return nil }

return title
case .postman:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Postman"
else { return nil }

return title
case .warp:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Warp"
else { return nil }
return title
case .slack:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Slack"
else { return nil }
return title
case .safari:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Safari"
else { return nil }
return title
case .imessage:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "iMessage"
else { return nil }
return title
case .canva:
guard
let title = extractPrefix(rawTitle, separator: " - ", minCount: 2),
title != "Canva",
title != "Home"
else { return nil }

return title
case .xcode:
return nil
case .chrome:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Chrome"
else { return nil }
return title
case .arcbrowser:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Arc"
else { return nil }
return title
}
}

Expand Down
12 changes: 11 additions & 1 deletion WakaTime/Extensions/NSRunningApplicationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ enum MonitoredApp: String, CaseIterable {
case figma = "com.figma.Desktop"
case canva = "com.canva.CanvaDesktop"
case postman = "com.postmanlabs.mac"
case warp = "dev.warp.Warp-Stable"
case slack = "com.tinyspeck.slackmacgap"
case safari = "com.apple.Safari"
case imessage = "com.apple.MobileSMS"
case chrome = "com.google.Chrome"
case arcbrowser = "company.thebrowser.Browser"

init?(from bundleId: String) {
if let app = MonitoredApp(rawValue: bundleId) {
Expand All @@ -18,7 +24,11 @@ enum MonitoredApp: String, CaseIterable {
MonitoredApp.allCases.map { $0.rawValue }
}

static let electronAppIds = [MonitoredApp.postman.rawValue, MonitoredApp.figma.rawValue, MonitoredApp.canva.rawValue]
static let electronAppIds = [MonitoredApp.postman.rawValue, MonitoredApp.figma.rawValue,
MonitoredApp.canva.rawValue, MonitoredApp.warp.rawValue,
MonitoredApp.slack.rawValue, MonitoredApp.safari.rawValue,
MonitoredApp.imessage.rawValue, MonitoredApp.chrome.rawValue,
MonitoredApp.arcbrowser.rawValue]
}

extension NSRunningApplication {
Expand Down
30 changes: 30 additions & 0 deletions WakaTime/Helpers/MonitoringManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@ class MonitoringManager {
entity: title,
language: "HTTP Request",
category: .debugging)
case .warp:
return HeartbeatData(
entity: title,
language: "Warp Activity",
category: .coding)
case .slack:
return HeartbeatData(
entity: title,
language: "Slack Activity",
category: .communicating)
case .safari:
return HeartbeatData(
entity: title,
language: "Safari Activity",
category: .browsing)
case .chrome:
return HeartbeatData(
entity: title,
language: "Chrome Activity",
category: .browsing)
case .arcbrowser:
return HeartbeatData(
entity: title,
language: "Arc Browser Activity",
category: .browsing)
case .imessage:
return HeartbeatData(
entity: title,
language: "iMessage Activity",
category: .communicating)
case .canva:
return HeartbeatData(
entity: title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
{"images":[{"size":"128x128","expected-size":"128","filename":"128.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"256x256","expected-size":"256","filename":"256.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"128x128","expected-size":"256","filename":"256.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"256x256","expected-size":"512","filename":"512.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"32x32","expected-size":"32","filename":"32.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"512x512","expected-size":"512","filename":"512.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"16x16","expected-size":"16","filename":"16.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"16x16","expected-size":"32","filename":"32.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"32x32","expected-size":"64","filename":"64.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"512x512","expected-size":"1024","filename":"1024.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"}]}
{
"images" : [
{
"filename" : "16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "32.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "64.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "256.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "512.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "1024.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
2 changes: 2 additions & 0 deletions WakaTime/WakaTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ enum Category: String {
case building
case debugging
case designing
case communicating
case browsing
}

protocol StatusBarDelegate: AnyObject {
Expand Down

0 comments on commit 605c910

Please sign in to comment.