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

hs.brightness.ambient() is returning "-1" (an error) #1970

Open
malob opened this issue Oct 26, 2018 · 5 comments
Open

hs.brightness.ambient() is returning "-1" (an error) #1970

malob opened this issue Oct 26, 2018 · 5 comments

Comments

@malob
Copy link
Contributor

malob commented Oct 26, 2018

Today I tried using hs.brightness.ambient(), but I wasn't able to get in to return anything other than “-1”.

I have a 2017 13-inch MacBook Pro with Touch Bar running macOS Mojave (10.14.0) and it's not connected to an external display. I chatted with @matthewfallshaw who has a 2018 15-inch MacBook Pro running Mojave, and he's also experiencing the same issue, so it seems unlikely that my sensor is on the fritz or that it's a software issue unique to my machine.

@cmsj
Copy link
Member

cmsj commented Oct 31, 2018

I wonder if newer MacBooks have a different underlying piece of hardware for getting ambient data.

We use the IOKit service AppleLMUController, but that is not present on touchbar macs and AFAIK there is no way to get the ambient light sensor values on those Macs, because it's all routed into the T chip :/

@latenitefilms
Copy link
Contributor

@cmsj - Is this relevant?

pirate/mac-keyboard-brightness#1 (comment)

@malob
Copy link
Contributor Author

malob commented Oct 31, 2018

@cmsj, I think you're right. I just did a little googling and found this post on the Apple Developer Forum which is pretty strong confirmation. It seems that there isn't any public API for getting data from this sensor on macOS (even the current API that HS is using isn't public actually).

I wonder if there are private APIs for this that someone has stumbled on. I haven't looked through the code, but there's a Dynamic Dark Mode app on GitHub that seems to be using the sensor (though maybe they are just querying screen brightness). I found it while working on a Spoon that provides the same functionality, which is how I came across this issue in the first place.

@Madd0g
Copy link

Madd0g commented May 4, 2021

I saw this - https://github.com/insidegui/DarkModeBuddy

not sure if it's relevant..

@cmsj
Copy link
Member

cmsj commented May 4, 2021

that seems very relevant, I think we can make that work. It's private API, so might break at any time, but it's not like the old ambient sensor code was particularly public/supported.

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

4 participants