Skip to content

Commit

Permalink
Better image presence + Close to perfect window detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbvfx committed Apr 3, 2022
1 parent c49e7e5 commit 6bd27bf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ And much more! (30 in total)
RPFX uses [his fork](https://github.com/PKBeam/SwordRPC) of [Azoy's SwordRPC](https://github.com/Azoy/SwordRPC).

## System Requirements
- macOS Big Sur (11.0) (Apple Silicon, Intel)
- macOS Big Sur (11.0-12.3) (Apple Silicon, Intel)
- Xcode and Discord (Stable or PTB) installed (otherwise this program isn't very useful)

## Usage
Expand Down
17 changes: 14 additions & 3 deletions RPFX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var rp = RichPresence()
let fn = getActiveFilename()
let ws = getActiveWorkspace()

//Xcode logo
rp.assets.largeImage = discordRPImageKeyXcode

// determine file type
// reconising file type only works on playgrounds for some reason
if let fileName = fn {
rp.details = "Editing \(fileName)"
// do we recognise this file type?
if let fileExt = getFileExt(fileName), discordRPImageKeys.contains(fileExt) {
rp.assets.largeImage = fileExt
rp.assets.smallImage = fileExt
} else {
rp.assets.largeImage = discordRPImageKeyDefault
rp.assets.smallImage = discordRPImageKeyDefault
}
}

Expand All @@ -43,10 +46,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

// Xcode was just launched?
if fn == nil && ws == nil {
if fn == "" && ws == nil {
rp.assets.largeImage = discordRPImageKeyXcode
rp.assets.smallImage = nil
rp.details = "No file open"
}

//Xcode is in Playground?
if fn == nil, let workspace = ws {
rp.assets.largeImage = discordRPImageKeyXcode
rp.assets.smallImage = discordRPImageKeys[20]
rp.state = "Editing \(withoutFileExt(workspace))" + ".playground"
}

// set timestamps
rp.timestamps.start = connectionStartDate
Expand Down
2 changes: 1 addition & 1 deletion RPFX/Applescript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func getActiveFilename() -> String? {

if !fileNames.contains(myString[0]) {
return window
}
}
}

return nil
Expand Down

0 comments on commit 6bd27bf

Please sign in to comment.