nriley / brightness

Command-line display brightness control for macOS.
BSD 2-Clause "Simplified" License
600 stars 54 forks source link

Doesn't work on MacBook Pro M3 #48

Open aik099 opened 9 months ago

aik099 commented 9 months ago

Doesn't work on MacBook Pro M3. I'm getting -536870201 error on every command.

I'm using macOS Sonoma 14.1.2.

→ brightness -l
display 0: main, active, awake, online, external, ID 0x2
brightness: failed to get brightness of display 0x2 (error -536870201)
display 1: active, awake, online, built-in, ID 0x1
brightness: failed to get brightness of display 0x1 (error -536870201)

→ brightness -d 0 1
brightness: failed to set brightness of display 0x2 (error -536870201)

→ brightness -d 1 1
brightness: failed to set brightness of display 0x1 (error -536870201)

P.S. The https://github.com/MonitorControl/MonitorControl project can change brightness, but it can't be used in CLI.

mrjustintime commented 7 months ago

I found many tools that promised to query or set the brightness for my MacBook M2, no tool worked so far. But there is an App called "Lunar" with different controls for display brightness etc.

Using that tool can have benefits, but many options are Pro features. The tool is good, but I don't really need any of their UI features. I just wanted to use the CLI to query the current brightness of my internal Mac screen or turn it on / off. The CLI is not a Pro feature.

My background:

External displays are connected through a Zigbee outlet. The goal: Shut down all monitors other than the one showing a movie played by Plex. Through homebridge / Home Assistant / Alexa Echo, I could turn off all monitors. As long as the HDMI cable is connected, the Mac does not disconnect the screens. That is a good fit for me, cause all monitors use their own windows and these should stay where they are.

The internal screen is special and has to be controlled by a service running the CLI as follows:

# install CLI once (after installing the app)
/Applications/Lunar.app/Contents/MacOS/Lunar install-cli

# query internal screen
~/.local/bin/lunar displays "Built-in" --read brightness | grep brightness | awk -F':' '{ print $2 }'

# turn internal screen off
~/.local/bin/lunar displays "Built-in" brightness 0

# turn internal screen on
~/.local/bin/lunar displays "Built-in" brightness 100

Disclaimer: I'm not associated with the company providing this tool. I just found no other tool working on my device. Maybe someone can benefit from this. Otherwise, the tool here should just be fixed to work as expected. That would be equally acceptable for me.

nriley commented 7 months ago

I use Lunar too — it is fabulous and its developer provides excellent support. Definitely would recommend anyone for whom brightness is inadequate check it out.

aik099 commented 7 months ago

@nriley , as this (brightness) app developer would you please consider fixing this issue?

nriley commented 7 months ago

I don't have a MacBook Pro M3 (nor do I have any plans to replace my perfectly functional M1 any time soon) so I have no way to test. I don't know what the problem is. I have minimal to zero time to work on open source projects these days. So, I guess the answer is no? Lunar is great, just use it.

aik099 commented 7 months ago

I don't have a MacBook Pro M3 (nor do I have any plans to replace my perfectly functional M1 any time soon) so I have no way to test. I don't know what the problem is. I have minimal to zero time to work on open source projects these days.

Someday maybe.

Lunar is great, just use it.

For now, I'm using MonitorControl, which is free and does just that: regulates brightness, but from UI only. It just can't do that from the command line or the AppleScript.

It has some code from https://github.com/waydabber/BetterDisplay project to support MacBook M3 (probably https://github.com/MonitorControl/MonitorControl/commit/c5c8bf1b3c22d3302ab395d8b6f588d59ad76ceb , but not sure), but I don't know Swift at all to make any use of it.

Akshat-vg commented 6 months ago

gives the same error on m1 Macs too, any fixes?

edit: works fine when built from source

arandorion commented 5 months ago

Doesn't work on my MacBook Air M2 either. I get the same error. It worked find on my ten-year-old MacBook Pro but not a new MacBook Air.

AndrewKeYanzhe commented 4 months ago

I have the same -536870201 error on M1 Macbook Pro 16

adriel commented 2 months ago

I have the same -536870201 error on M1 Macbook Pro 16

Build it from source. https://github.com/nriley/brightness#install-from-source

khurshid-alam commented 2 months ago

@adriel Can you upload the binary here, built from source for M1 ? Thanks.

adriel commented 2 months ago

brightness apple silicon binary.zip

Here ya go @khurshid-alam

jammi commented 3 weeks ago

I have the same issue (when installed from brew), but @adriel 's binary works.

aik099 commented 3 weeks ago

The binary built from the source adjusts the brightness of the built-in display, but not the external one. Running brightness -l command on a compiled binary shows:

display 0: main, active, awake, online, external, ID 0x5
./brightness: unable to get brightness of display 0x5
display 1: active, awake, online, built-in, ID 0x1
display 1: brightness 0.000000