forked from MonitorControl/MonitorControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various Enhancements (MonitorControl#66)
* Update to Swift 5.0 and run `swiftformat`. * Refactor `MediaKeyTap` start/restart. * Remove useless comments. * Reorder files. * Add German translation. * Switch to Carthage. * Use `DDC.swift`. * Add `NSScreen` extension. * Simplify menu layout. * Hide the display’s built-in OSD. * Fix launch at login helper. * Fix `quitClicked` connection. * Refactor build phases. * Use `os_log` instead of `print`. * Use more specific check for `minReplyDelay`. * Add whitelist.
- Loading branch information
1 parent
830878e
commit 6e91c71
Showing
45 changed files
with
1,275 additions
and
1,367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,3 @@ | ||
Carthage | ||
|
||
# Created by https://www.gitignore.io/api/macos,xcode,cocoapods | ||
|
||
### CocoaPods ### | ||
## CocoaPods GitIgnore Template | ||
|
||
# CocoaPods - Only use to conserve bandwidth / Save time on Pushing | ||
# - Also handy if you have a large number of dependant pods | ||
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE | ||
Pods/ | ||
|
||
### macOS ### | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Xcode ### | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## Build generated | ||
build/ | ||
DerivedData/ | ||
|
||
## Various settings | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata/ | ||
|
||
## Other | ||
*.moved-aside | ||
*.xccheckout | ||
*.xcscmblueprint | ||
|
||
### Xcode Patch ### | ||
*.xcodeproj/* | ||
!*.xcodeproj/project.pbxproj | ||
!*.xcodeproj/xcshareddata/ | ||
!*.xcworkspace/contents.xcworkspacedata | ||
/*.gcno | ||
*.xcuserdatad |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--indent 2 | ||
--ranges no-space | ||
--self insert | ||
--exponentcase lowercase | ||
--exclude Carthage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github "the0neyouseek/MediaKeyTap" "master" | ||
github "reitermarkus/DDC.swift" "master" | ||
github "rnine/AMCoreAudio" | ||
github "shpakovski/MASPreferences" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github "reitermarkus/DDC.swift" "9a6a249b4b222e67b1393eecd7ac9eb35dff34a9" | ||
github "rnine/AMCoreAudio" "3.2.1" | ||
github "shpakovski/MASPreferences" "1.3" | ||
github "the0neyouseek/MediaKeyTap" "abfe09f53ccabb1aa14a0f4ab99cfb8812f41919" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Cocoa | ||
|
||
extension CGDirectDisplayID { | ||
public var vendorNumber: UInt32? { | ||
return CGDisplayVendorNumber(self) | ||
} | ||
|
||
public var modelNumber: UInt32? { | ||
return CGDisplayModelNumber(self) | ||
} | ||
|
||
public var serialNumber: UInt32? { | ||
return CGDisplaySerialNumber(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import DDC | ||
|
||
extension EDID { | ||
public func displayName() -> String? { | ||
let descriptors = [self.descriptors.0, self.descriptors.1, self.descriptors.2, self.descriptors.3] | ||
|
||
for descriptor in descriptors { | ||
switch descriptor { | ||
case let .displayName(name): | ||
return name | ||
default: | ||
continue | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
public func serialNumber() -> String? { | ||
let descriptors = [self.descriptors.0, self.descriptors.1, self.descriptors.2, self.descriptors.3] | ||
|
||
for descriptor in descriptors { | ||
switch descriptor { | ||
case let .serialNumber(number): | ||
return number | ||
default: | ||
continue | ||
} | ||
} | ||
|
||
return String(self.serialNumber) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import Cocoa | ||
|
||
extension NSScreen { | ||
public var displayID: CGDirectDisplayID { | ||
return (self.deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] as? CGDirectDisplayID)! | ||
} | ||
|
||
public var vendorNumber: UInt32? { | ||
switch self.displayID.vendorNumber { | ||
case 0xFFFF_FFFF: | ||
return nil | ||
case let vendorNumber: | ||
return vendorNumber | ||
} | ||
} | ||
|
||
public var modelNumber: UInt32? { | ||
switch self.displayID.modelNumber { | ||
case 0xFFFF_FFFF: | ||
return nil | ||
case let modelNumber: | ||
return modelNumber | ||
} | ||
} | ||
|
||
public var serialNumber: UInt32? { | ||
switch self.displayID.serialNumber { | ||
case 0x0000_0000: | ||
return nil | ||
case let serialNumber: | ||
return serialNumber | ||
} | ||
} | ||
|
||
public var displayName: String? { | ||
var servicePortIterator = io_iterator_t() | ||
|
||
let status = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"), &servicePortIterator) | ||
guard status == KERN_SUCCESS else { | ||
return nil | ||
} | ||
|
||
defer { | ||
assert(IOObjectRelease(servicePortIterator) == KERN_SUCCESS) | ||
} | ||
|
||
while case let object = IOIteratorNext(servicePortIterator), object != 0 { | ||
let dict = (IODisplayCreateInfoDictionary(object, UInt32(kIODisplayOnlyPreferredName)).takeRetainedValue() as NSDictionary as? [String: AnyObject])! | ||
|
||
if dict[kDisplayVendorID] as? UInt32 == self.vendorNumber, | ||
dict[kDisplayProductID] as? UInt32 == self.modelNumber, | ||
dict[kDisplaySerialNumber] as? UInt32 == self.serialNumber { | ||
if let productName = dict["DisplayProductName"] as? [String: String], | ||
let firstKey = Array(productName.keys).first { | ||
return productName[firstKey]! | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
public var isBuiltin: Bool { | ||
return CGDisplayIsBuiltin(self.displayID) != 0 | ||
} | ||
|
||
public static func getByDisplayID(displayID: CGDirectDisplayID) -> NSScreen? { | ||
return NSScreen.screens.first { $0.displayID == displayID } | ||
} | ||
} |
Oops, something went wrong.