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. Added setScale() method (using a workaround). Added wakeup feature to turnOn() method
  • Loading branch information
Kalmat committed Apr 19, 2024
1 parent 8875b51 commit b57795e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/pymonctl/_pymonctl_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,10 @@ def _loadDisplayServices():
def _loadCoreDisplay():
# Another option is to use Core Display Services
try:
cd: ctypes.CDLL = ctypes.cdll.LoadLibrary(ctypes.util.find_library("CoreDisplay"))
lib = ctypes.util.find_library("CoreDisplay")
if not lib:
return None
cd: ctypes.CDLL = ctypes.cdll.LoadLibrary(lib)
cd.CoreDisplay_Display_SetUserBrightness.argtypes = [ctypes.c_int, ctypes.c_double]
cd.CoreDisplay_Display_GetUserBrightness.argtypes = [ctypes.c_int, ctypes.c_void_p]
except:
Expand All @@ -738,11 +741,17 @@ class _CFString(ctypes.Structure):

CFStringRef = ctypes.POINTER(_CFString)

CF: ctypes.CDLL = ctypes.cdll.LoadLibrary(ctypes.util.find_library("CoreFoundation"))
lib = ctypes.util.find_library("CoreFoundation")
if not lib:
return None, None, None
CF: ctypes.CDLL = ctypes.cdll.LoadLibrary(lib)
CF.CFStringCreateWithCString.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_uint32]
CF.CFStringCreateWithCString.restype = CFStringRef

iokit: ctypes.CDLL = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))
lib = ctypes.util.find_library('IOKit')
if not lib:
return None, None, None
iokit: ctypes.CDLL = ctypes.cdll.LoadLibrary(lib)
iokit.IODisplayGetFloatParameter.argtypes = [ctypes.c_void_p, ctypes.c_uint, CFStringRef, ctypes.POINTER(ctypes.c_float)]
iokit.IODisplayGetFloatParameter.restype = ctypes.c_int
iokit.IODisplaySetFloatParameter.argtypes = [ctypes.c_void_p, ctypes.c_uint, CFStringRef, ctypes.c_float]
Expand Down

0 comments on commit b57795e

Please sign in to comment.