Skip to content

Commit

Permalink
ALL: findMonitor() returns a list of Monitor instances
Browse files Browse the repository at this point in the history
MACOS: Added contrast(), setContrast(), isOn() and isAttached(), improved setMode()
  • Loading branch information
Kalmat committed Aug 24, 2023
1 parent 8d7deff commit c565ba8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
Binary file modified dist/PyMonCtl-0.0.12-py3-none-any.whl
Binary file not shown.
53 changes: 27 additions & 26 deletions src/pymonctl/_pymonctl_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,32 +368,33 @@ def contrast(self) -> Optional[int]:

def setContrast(self, contrast: Optional[int]):
# https://searchcode.com/file/2207916/pyobjc-framework-Quartz/PyObjCTest/test_cgdirectdisplay.py/
try:
ret, redMin, redMax, redGamma, greenMin, greenMax, greenGamma, blueMin, blueMax, blueGamma = (
CG.CGGetDisplayTransferByFormula(self.handle, None, None, None, None, None, None, None, None, None))
if ret == 0:
newRedGamma = contrast / 100
if newRedGamma < redMin:
newRedGamma = redMin
elif newRedGamma > redMax:
newRedGamma = redMax
newGreenGamma = contrast / 100
if newGreenGamma < greenMin:
newGreenGamma = greenMin
elif newGreenGamma > greenMax:
newGreenGamma = greenMax
newBlueGamma = contrast / 100
if newBlueGamma < blueMin:
newBlueGamma = blueMin
elif newBlueGamma > blueMax:
newBlueGamma = blueMax
ret = CG.CGSetDisplayTransferByFormula(self.handle,
redMin, redMax, newRedGamma,
greenMin, greenMax, newGreenGamma,
blueMin, blueMax, newBlueGamma
)
except:
pass
if contrast is not None:
try:
ret, redMin, redMax, redGamma, greenMin, greenMax, greenGamma, blueMin, blueMax, blueGamma = (
CG.CGGetDisplayTransferByFormula(self.handle, None, None, None, None, None, None, None, None, None))
if ret == 0:
newRedGamma = contrast / 100
if newRedGamma < redMin:
newRedGamma = redMin
elif newRedGamma > redMax:
newRedGamma = redMax
newGreenGamma = contrast / 100
if newGreenGamma < greenMin:
newGreenGamma = greenMin
elif newGreenGamma > greenMax:
newGreenGamma = greenMax
newBlueGamma = contrast / 100
if newBlueGamma < blueMin:
newBlueGamma = blueMin
elif newBlueGamma > blueMax:
newBlueGamma = blueMax
ret = CG.CGSetDisplayTransferByFormula(self.handle,
redMin, redMax, newRedGamma,
greenMin, greenMax, newGreenGamma,
blueMin, blueMax, newBlueGamma
)
except:
pass

@property
def mode(self) -> Optional[DisplayMode]:
Expand Down

0 comments on commit c565ba8

Please sign in to comment.