Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Auto change doesn't works in my configuration #3

Closed
idoo opened this issue Feb 1, 2018 · 45 comments · Fixed by #4
Closed

Auto change doesn't works in my configuration #3

idoo opened this issue Feb 1, 2018 · 45 comments · Fixed by #4

Comments

@idoo
Copy link

idoo commented Feb 1, 2018

@Exelord thank you for implementing this, I've looked to way how I can get access from light sensor in js :)

Does it work in current Mac OS? looks like we don't have access to sensor now, is it right?

I have macbook pro 2016:
Atom: 1.23.3 x64
mac os 10.13.3

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

:)
I'm using dark-mode all the time and on the latest osx and atom, it works perfectly :)

Take a look to package.json There is a package responsible for ambient light sensor. Anyway. It's also implemented already in Chrome, but not activated by default

@idoo
Copy link
Author

idoo commented Feb 1, 2018

yep, I looked on this, and even tried to compile it

maybe something wrong with my settings — are you using default values?

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018 via email

@idoo
Copy link
Author

idoo commented Feb 1, 2018

now I'm trying your package in atom, is it possible to get some data from atom console? when I'm using
new AmbientLightSensorReading(null)
it returns
AmbientLightSensorReading {illuminance: 0, timeStamp: 325720.09} for me
so, I guess there are no data from a sensor, isn't it?

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

I see, but is the package working correctly for you or it is just the problem with accessing the sensor package?

@idoo
Copy link
Author

idoo commented Feb 1, 2018

I install it, set parameters like here
http://take.ms/wqZgy
and put some light on my sensor, and nothing was changed :(
then I tried to debug it from atom console, and don't know how to get access to sensor :(

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

screen shot 2018-02-01 at 09 54 09

Please ensure to turn auto mode to on

@idoo
Copy link
Author

idoo commented Feb 1, 2018

yep, I switched it on as well

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

Did you restart the atom? What kind of mac you have?

@idoo
Copy link
Author

idoo commented Feb 1, 2018

yep, I did, macbook pro 2016

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

Hmm, same. Is the switcher working correctly?

@idoo
Copy link
Author

idoo commented Feb 1, 2018

yep, I can switch manually, but can't automatically

I did debug here — lib/ambient-light.js:41

and looks value is always 0 even my screen is changing the brightness level

I have:
Atom: 1.23.3 x64
mac os 10.13.3

@idoo idoo changed the title mac support auto change doesn't works in my configuration Feb 1, 2018
@idoo idoo changed the title auto change doesn't works in my configuration Auto change doesn't works in my configuration Feb 1, 2018
@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

darkMode = atom.packages.getAvailablePackages().find((p) => {return p.name == 'dark-mode'})
Ambient = require(`${darkMode.path}/lib/ambient-light`);
sensor = new Ambient();
sensor._lux();

Try it out in developer console and check what is the result of sensor._lux()

@idoo
Copy link
Author

idoo commented Feb 1, 2018

I did almost same when I put debugger in lib/ambient-light.js:41 — value is 0
maybe I have add/update some library?

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

:/ looks bad... and weird. Try to execute this file: https://github.com/jamo/ambientlight/blob/master/ambientlight.mm

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018

Its definitely not a problem of the package, rather the system configuration.

@idoo
Copy link
Author

idoo commented Feb 1, 2018

yep, I think so

./ambientlight                                                                                                                                                                                               
failed to find ambient light sensors

@idoo
Copy link
Author

idoo commented Feb 1, 2018

@Exelord last question, do you have touchbar?
looks like here is same issue with macbook with touchbar
Dunedan/mbp-2016-linux#16

@Exelord
Copy link
Owner

Exelord commented Feb 1, 2018 via email

@QuentinRoy
Copy link

Same issue here. I tried your snippet above in Atom's console. Value is 0 as well. I believe I have the exact same issue as @idoo. I also have a MacBook equipped with their new (useless) touchbar. So it might be a good lead.

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

Im going to switch to native api https://developer.mozilla.org/en-US/docs/Web/API/Ambient_Light_Events

@idoo
Copy link
Author

idoo commented Feb 22, 2018

@Exelord sadly, it's doesn't work as well, coz as I got it's using same AppleLMUController :(
and ask I can see it works only in FF now

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

checkout this example:

window.addEventListener('devicelight', function(event) { console.log('Light: ', event.value) })

It works, I have it already implemented. Just testing now for a few days to setup correct threshold

@QuentinRoy
Copy link

QuentinRoy commented Feb 22, 2018

It is (partially) supported on chrome since quite some time so it should be supported by nodejs as well. However it does not work on my laptop (I just tried both your snippet and this website).

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

Hmm, in the latest atom it works perfectly fine

@QuentinRoy
Copy link

QuentinRoy commented Feb 22, 2018

It does look like a good idea to rely on a standard (though unfinished). In that case you might choose to wait for Chromium to fix it (not sure when that will happen), meaning that you have nothing to do. An other option would be to wait for an update from ambientlight. Its maintainer mentioned that he was willing to have a look at it (c.f. jamo/ambientlight#1).

@idoo
Copy link
Author

idoo commented Feb 22, 2018

I did

window.addEventListener('devicelight', function(event) {
  console.log(event.value);
});

and there is no result in latest FF, Chrome, Safari

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

Could you try that one in the atom?

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

@QuentinRoy sure... For now, I will migrate to browser api, but depending what will came faster we will react with a proper fix.

@idoo
Copy link
Author

idoo commented Feb 22, 2018

looks like atom returns Infinity if there are no sensor data
bridge 2018-02-22 20-29-03

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

I will open a PR soon, so you will be able to test it

@idoo
Copy link
Author

idoo commented Feb 22, 2018

looks like it's doesn't work in FF
what we can do today 2018-02-22 20-30-49

Chrome/Safari/ — both Not supported

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

Yes, but atom is based on chromium.

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

and we need only window.ondevicelight :)

@idoo
Copy link
Author

idoo commented Feb 22, 2018

Funny, in Atom it works, but with Infinity as constant
bridge 2018-02-22 20-34-45

@idoo
Copy link
Author

idoo commented Feb 22, 2018

I just tested in macbook 2017 without touchbar, where data though AppleLMUController work well, and in Chrome ondevicelight and AmbientLightSensor is NotSupported

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

yes.. in chrome ondevicelight is not supported yet. But chorme != chromium

@idoo
Copy link
Author

idoo commented Feb 22, 2018

I know, just funny :)

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

It looks like there is no support for now mackbooks yet :/ Or the API is private

@idoo
Copy link
Author

idoo commented Feb 22, 2018

@Exelord btw, #2 partially it can solve our pain :) I used it same configuration in emacs and it works well based on geo-coordinates and sunrise data

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

Yes, that would be pretty cool feature :)

@idoo
Copy link
Author

idoo commented Feb 22, 2018

@Exelord navigator.geolocation.getCurrentPosition(console.log) works well :)
https://github.com/mourner/suncalc

@Exelord
Copy link
Owner

Exelord commented Feb 22, 2018

Look like getting current location is not possible in Atom. The only thing we can do is to use current timezone

@idoo
Copy link
Author

idoo commented Feb 22, 2018

@Exelord

if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(msg) {
        console.log(msg);
  }, function(err) {
        console.log(err);
  });
} else {
  error('not supported');
}

makes request to google, but it returns 400
"Network location provider at 'https://www.googleapis.com/' : Returned error code 400."

As option, it can be static longitude-latitude coordinates

Probably it require https://github.com/electron/electron/blob/master/docs/api/environment-variables.md#google_api_key

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

Successfully merging a pull request may close this issue.

3 participants