Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change the brightness of main display #26

Open
WrathOP opened this issue Aug 30, 2022 · 1 comment
Open

Cannot change the brightness of main display #26

WrathOP opened this issue Aug 30, 2022 · 1 comment

Comments

@WrathOP
Copy link

WrathOP commented Aug 30, 2022

def setBrightness(self, brightness):
    """
    :param brightness: The desired brightness, from 0 to 1.
    """
    error = iokit["IODisplaySetFloatParameter"](self.__servicePort, 0, iokit["kDisplayBrightness"], brightness)
    if error:
        if self.isMain:
            raise DisplayError("Cannot manage brightness on display \"{}\"".format(self.tag))
        else:
            raise DisplayError(
                "Display \"{}\"\'s brightness cannot be set.\n"
                "External displays may not be compatible with Display Manager. "
                "Try setting manually on device hardware.".format(self.tag))

I wanted to use this code for my project as I am unable to find a way to change the macos brightness from python and this library is one caught my eye but it clearly doesnt support changing main display brightness , or I am just understanding it wrong.

@Alexandro1112
Copy link

Alexandro1112 commented Apr 17, 2023

I have the solution, setBrightness also doesn't work on macOS 13.0 Ventura, I can propose using this code for setup screen brightness, function IKMonitorBrightnessController, bellow script:

from Quartz import IKMonitorBrightnessController


def setBrightness(level: float):
    success = IKMonitorBrightnessController.alloc().setBrightnessOnAllDisplays_(level)
    if not success is None:
        raise ValueError()


setBrightness(0.5)

However, this script set brightness for all displays, but I count it is alternative solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants