Skip to content

Commit

Permalink
ALL: Added saveSetup() and restoreSetup(). Fixed / Improved watchdog …
Browse files Browse the repository at this point in the history
…(especially in Linux). Fixed / improved setPosition() method

LINUX: Added ewmhlib as separate module. Fixed watchdog (freezing randomly invoking screen_resources and get_output_info), fixed workarea crash (some apps/environments do not set it), improved to work almost fine in Manjaro/KDE, avoid crashing in Wayland for "fake" :1 display (though module won't likely work)
WIN32: Fixed dev.StateFlags returning weird values for multi-monitor. Fixed GetAwarenessFromDpiAwarenessContext not supported on Windows Server
MACOS: Replaced display-manager-lib by other alternatives which seem to work in several macOS versions (brightness only) Added setScale() method (using a workaround). Added wakeup feature to turnOn() method
  • Loading branch information
Kalmat committed Apr 18, 2024
1 parent b4e7877 commit c1491a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/pymonctl/_pymonctl_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def setOrientation(self, orientation: Optional[Union[int, Orientation]]):
options = rotateCode | angleCodes[(orientation*90) % 360]

try:
ret = IOServiceRequestProbe(self._ioservice, options)
ret = globals()["IOServiceRequestProbe"](self._ioservice, options)
except:
ret = 1
if ret != 0:
Expand Down Expand Up @@ -436,7 +436,7 @@ def brightness(self) -> Optional[int]:
self._ioservice = _loadIOKit(self.handle)
if self._ioservice is not None:
try:
(ret, value) = IODisplayGetFloatParameter(self._ioservice, 0, kIODisplayBrightnessKey, None)
(ret, value) = globals()["IODisplayGetFloatParameter"](self._ioservice, 0, globals()["kIODisplayBrightnessKey"], None)
except:
ret = 1
if ret == 0:
Expand Down Expand Up @@ -487,7 +487,7 @@ def setBrightness(self, brightness: Optional[int]):
if self._ioservice is not None:
value = ctypes.c_float(brightness / 100)
try:
ret = IODisplaySetFloatParameter(self._ioservice, 0, kIODisplayBrightnessKey, value)
ret = globals()["IODisplaySetFloatParameter"](self._ioservice, 0, globals()["kIODisplayBrightnessKey"], value)
except:
ret = 1
if ret != 0:
Expand Down Expand Up @@ -755,14 +755,14 @@ def _loadIOKit(displayID = Quartz.CGMainDisplayID()):
globals()['kIODisplayBrightnessKey'] = CF.CFSTR("brightness")

try:
service = Quartz.CGDisplayIOServicePort(displayID)
service: Optional[int] = Quartz.CGDisplayIOServicePort(displayID)
except:
service: Optional[int] = None
service = None

if not service:
err, service = IOServiceGetMatchingService(
kIOMasterPortDefault,
IOServiceMatching(b'IODisplayConnect')
err, service = globals()["IOServiceGetMatchingService"](
globals()["kIOMasterPortDefault"],
globals()["IOServiceMatching"](b'IODisplayConnect')
)
if err != 0 or not service:
service = None
Expand Down
9 changes: 9 additions & 0 deletions typings/objc.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Any


class loadBundleFunctions(str):
def __getattr__(self, name: str) -> Any: ...

class loadBundleVariables(str):
def __getattr__(self, name: str) -> Any: ...

0 comments on commit c1491a1

Please sign in to comment.