Exelord / dark-mode

Package for Atom Editor which allows you to switch to dark mode and light mode theme.
MIT License
16 stars 4 forks source link

Auto change doesn't works in my configuration #3

Closed idoo closed 6 years ago

idoo commented 6 years ago

@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 commented 6 years ago

:) 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 commented 6 years ago

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

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

Exelord commented 6 years ago

On more thing. Where are u using it? I mean in what environment. Atom package, node server, browser? On Thu, 1 Feb 2018 at 09:42 Ivan Verevkin notifications@github.com wrote:

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

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Exelord/dark-mode/issues/3#issuecomment-362196839, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZrv8d-Ab2W9AsjKIhnx1iTvI0mEEcmks5tQXkKgaJpZM4R1PAr .

idoo commented 6 years ago

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 commented 6 years ago

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

idoo commented 6 years ago

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 commented 6 years ago
screen shot 2018-02-01 at 09 54 09

Please ensure to turn auto mode to on

idoo commented 6 years ago

yep, I switched it on as well

Exelord commented 6 years ago

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

idoo commented 6 years ago

yep, I did, macbook pro 2016

Exelord commented 6 years ago

Hmm, same. Is the switcher working correctly?

idoo commented 6 years ago

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

Exelord commented 6 years ago
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 commented 6 years ago

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 commented 6 years ago

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

Exelord commented 6 years ago

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

idoo commented 6 years ago

yep, I think so

./ambientlight                                                                                                                                                                                               
failed to find ambient light sensors
idoo commented 6 years ago

@Exelord last question, do you have touchbar? looks like here is same issue with macbook with touchbar https://github.com/Dunedan/mbp-2016-linux/issues/16

Exelord commented 6 years ago

No. :/ On Thu, 1 Feb 2018 at 11:06 Ivan Verevkin notifications@github.com wrote:

@Exelord https://github.com/exelord last question, do you have touchbar?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Exelord/dark-mode/issues/3#issuecomment-362218462, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZrv6rqgbJHFSVOchAEvUg3Dt_PSkPlks5tQYyngaJpZM4R1PAr .

QuentinRoy commented 6 years ago

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 commented 6 years ago

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

idoo commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Hmm, in the latest atom it works perfectly fine

QuentinRoy commented 6 years ago

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. https://github.com/jamo/ambientlight/issues/1).

idoo commented 6 years ago

I did

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

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

Exelord commented 6 years ago

Could you try that one in the atom?

Exelord commented 6 years ago

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

idoo commented 6 years ago

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

Exelord commented 6 years ago

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

idoo commented 6 years ago

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 commented 6 years ago

Yes, but atom is based on chromium.

Exelord commented 6 years ago

and we need only window.ondevicelight :)

idoo commented 6 years ago

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

idoo commented 6 years ago

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

Exelord commented 6 years ago

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

idoo commented 6 years ago

I know, just funny :)

Exelord commented 6 years ago

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

idoo commented 6 years ago

@Exelord btw, https://github.com/Exelord/dark-mode/issues/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 commented 6 years ago

Yes, that would be pretty cool feature :)

idoo commented 6 years ago

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

Exelord commented 6 years ago

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

idoo commented 6 years ago

@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

idoo commented 6 years ago

for history — asked for help in chromium issues tracker https://bugs.chromium.org/p/chromium/issues/detail?id=817725&can=2&start=0&num=100&q=-component%3ABlink%3ESensor%20&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified&groupby=&sort=