Live data from Hacker News

Setting Emacs theme based on ambient light

matthewbilyeu.com

11–20 of 27 posts

Re: Setting Emacs theme based on ambient light

#11

Neat. I've done that on the occasional web site, although matched to time of sunrise/sunset. I imagine reading from a light sensor is more accurate, but it isn't available everywhere yet: https://caniuse.com/#search=ambient

If you are running Linux, iio-sensor-proxy might be worth a try.

Re: Setting Emacs theme based on ambient light

#12
post #6

is the background color really the problem? I though screen brightness was a more issue, for example: continue using your light theme but lower down the brightness, most of your websites are going to be white backgrounds, switch between dark and light background frequently strains more the eyes, looking for the link where I read this.

On my Atari I made a program to invert all colors with a button combination so I could switch between applications as needed. There are some programs around that does that in windows now. If you have nVidia drivers they can invert but I don't think that can be done with a button. Windows magnifyer has an inverter built in too.

f.lux nicely takes away only the blue light but this isn't always enough for the bright backgrounds of modern homepages and text editors.

Re: Setting Emacs theme based on ambient light

#14
post #13

How to do it on linux? there's a package iio-sensor-proxy but who knows how to read out the ambient light from terminal.

Only way I've managed is using pillow's ImageStat against a webcam image.

If Gnome can read your ambient sensor then monitor-sensor is the cli tool from that package to look at.

Re: Setting Emacs theme based on ambient light

#15
post #6

is the background color really the problem? I though screen brightness was a more issue, for example: continue using your light theme but lower down the brightness, most of your websites are going to be white backgrounds, switch between dark and light background frequently strains more the eyes, looking for the link where I read this.

In my own experience, many devices either:

* do not offer granular enough control of the brightness on the low end (the backlight is either kind of dim, or nearly/completely off, with no in-between setting), or they

* do not have enough contrast at low brightness to read easily.

In either case, the display is more readable by having the backlight on bright, and darkening most of the display (by changing the background color).

Of course, this does not apply to all displays, but every display has pretty fine control its total light output by changing the colors it is displaying.

Re: Setting Emacs theme based on ambient light

#19
You can leverage the existing sunrise-sunset function to determine if it is day on night and change your theme accordingly.

(defun daytime? () (sunrise-sunset) (let ((range (mapcar 'car (butlast (solar-sunrise-sunset (calendar-current-date)))))) (let ((sunrise (car range)) (sunset (cadr range)) (now (string-to-number (format-time-string "%H")))) ((if (daytime?) (light) (dark))

Re: Setting Emacs theme based on ambient light

#20
post #3

I've had this in my vimrc for a little while: let hr = (strftime('%H')) if hr >= 17 set background=dark elseif hr >= 7 set background=light elseif hr >= 0 set background=dark endif Using a light sensor would be cool, but I actually work from a desktop PC most of the time, so no sensor. I guess the next best thing would be something like f.lux does: query some web service for the sunset time at your current location.

It is possible to purchase a small USB lux meter:

http://www.yoctopuce.com/EN/products/usb-environmental-senso...

I use one to automatically adjust the brightness of my Dell display.

Post reply on HN