Skip to content

Commit

Permalink
Fix screen names on Apple silicon Macs
Browse files Browse the repository at this point in the history
Fixes #78
  • Loading branch information
sindresorhus committed Mar 23, 2022
1 parent 59a3977 commit aab677a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Example/Sources/Example/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ aperture.onFinish = {

aperture.start()

print("Recording the screen for 5 seconds")
print("Available screens:", Aperture.Devices.screen().map(\.name).joined(separator: ", "))
print("Recording screen for 5 seconds")

delay(seconds: 5) {
aperture.stop()
Expand Down
4 changes: 4 additions & 0 deletions Sources/Aperture/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ extension NSScreen {

// TODO: Use the built-in `.localizedName` property instead when targeting macOS 10.15. I can then drop this and `infoForCGDisplay`.
var name: String {
if #available(macOS 10.15, *) {
return localizedName
}

guard let info = infoForCGDisplay(id, options: kIODisplayOnlyPreferredName) else {
return "Unknown screen"
}
Expand Down

0 comments on commit aab677a

Please sign in to comment.