Skip to content

Support M1 Macs using DisplayServicesGetBrightness/DisplayServicesSetBrightness#36

Merged
nriley merged 1 commit intonriley:masterfrom
jtbandes:master
Feb 28, 2021
Merged

Support M1 Macs using DisplayServicesGetBrightness/DisplayServicesSetBrightness#36
nriley merged 1 commit intonriley:masterfrom
jtbandes:master

Conversation

@jtbandes
Copy link
Copy Markdown
Contributor

I found that these SPI functions work to get and set the brightness on my M1 MacBook Air. Fixes #34.

I have not tested this with any other system/configuration, so will need help from others to test thoroughly.

  • Extracted functions from the main loop to avoid it getting too complicated.
  • Also made minor changes to fix a warning about brightness being uninitialized.

…Brightness

- Tested on a M1 MacBook Air running Big Sur, for the built-in display.
- Extracted functions from the main loop to avoid it getting too complicated.
- Also made minor changes to fix a warning about `brightness` being uninitialized.
@nriley
Copy link
Copy Markdown
Owner

nriley commented Feb 22, 2021

Thanks! Testing help appreciated.

nriley referenced this pull request in Hammerspoon/hammerspoon Feb 22, 2021
Mike-Woolley added a commit to Mike-Woolley/brightness that referenced this pull request Feb 28, 2021
Mike-Woolley added a commit to Mike-Woolley/brightness that referenced this pull request Feb 28, 2021
@Mike-Woolley
Copy link
Copy Markdown

Thanks @jtbandes, this change works form me on both my M1 & Intel MacBooks 😄

However one line of the PR breaks brightness -l.
Reverting that line makes everything good - I have put a comment in the commit diff to indicate where.

Comment thread brightness.c

float brightness;
if (action == ACTION_LIST) {
if (argc > 0) usage();
Copy link
Copy Markdown

@Mike-Woolley Mike-Woolley Feb 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks brightness -l.
Not sure what the purpose is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to fix an uninitialized variable warning, but I guess I made a mistake. Thanks for catching — I’ll submit a fix soon.

@nriley nriley self-assigned this Feb 28, 2021
@nriley nriley merged commit 09d5e57 into nriley:master Feb 28, 2021
@jtbandes
Copy link
Copy Markdown
Contributor Author

@nriley, you might want to revert the if (argc > 0) usage() change as recommended by @Mike-Woolley. I think when I was reading the code I didn't realize that argc was modified.

@nriley
Copy link
Copy Markdown
Owner

nriley commented Feb 28, 2021

Sorry, I did not mean to commit that as is. I've got a cleanup commit incoming.

@nriley
Copy link
Copy Markdown
Owner

nriley commented Feb 28, 2021

OK, updated and tested on all the Macs I have access to. Hopefully this works for everyone else too. Thanks again for the contribution!

@new3gum2
Copy link
Copy Markdown

new3gum2 commented Sep 17, 2022

tested on M1 MacBook Pro 17,1.
Fails to work showing display id as 0x1 and error -536870201

@nriley
Copy link
Copy Markdown
Owner

nriley commented Sep 18, 2022

@new3gum2 are you building from source? If so, what macOS version and are you using the internal display?

@new3gum2
Copy link
Copy Markdown

@new3gum2 are you building from source? If so, what macOS version and are you using the internal display?
Sorry I didn't have time to test further, I used the make file and it worked like charm. it is macOS Monterey
I was trying the compiled versions from brew and MacPorts neither of those worked. But the source compile worked.

@KuSi833
Copy link
Copy Markdown

KuSi833 commented Oct 9, 2022

@new3gum2 are you building from source? If so, what macOS version and are you using the internal display?
Sorry I didn't have time to test further, I used the make file and it worked like charm. it is macOS Monterey
I was trying the compiled versions from brew and MacPorts neither of those worked. But the source compile worked.

Can also confirm building from source works, but was getting the same error when I installed it with brew.

@mrtvocich
Copy link
Copy Markdown

Hi all, I have first tried to install brightness through Homebrew, but the app was returning an error. After compiling locally

git clone https://github.com/nriley/brightness.git      
make                                                    
sudo cp brightness /usr/local/bin/brightness   

it works great, thank you guys!

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

Successfully merging this pull request may close these issues.

Failing on Big Sur with Apple Silicon

6 participants