Skip to content

Support M1 Macs using DisplayServicesGetBrightness/DisplayServicesSetBrightness#36

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

Support M1 Macs using DisplayServicesGetBrightness/DisplayServicesSetBrightness#36
nriley merged 1 commit into
nriley: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

nriley commented Feb 22, 2021

Copy link
Copy Markdown
Owner

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();

@Mike-Woolley Mike-Woolley Feb 28, 2021

Copy link
Copy Markdown

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

nriley commented Feb 28, 2021

Copy link
Copy Markdown
Owner

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

@nriley

nriley commented Feb 28, 2021

Copy link
Copy Markdown
Owner

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

new3gum2 commented Sep 17, 2022

Copy link
Copy Markdown

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

@nriley

nriley commented Sep 18, 2022

Copy link
Copy Markdown
Owner

@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

KuSi833 commented Oct 9, 2022

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.

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