flux and hue
[f.lux](www.justgetflux.com) is pretty awesome. Now that my room is lit by hue, I wanted a way to make my room colour temperature match my screen. This requires a few ingredients:
- a working hue setup, obviously
- some way to control the lights from the command line. You don’t actually need anything for this, since the bridge actually just accepts HTTP requests to set values, but it’s nice to have a wrapper so you don’t have to worry. I used hue-cli – which, beware, is not the only hue-cli package out there. It has a command
hue lights all red
which does what you expect - some way to get the desired colour temperature when the script is run. Ideally I’d use the f.lux one, and I’ve emailed the devs to ask, but in the meantime the open-source f.lux clone redshift will tell you what it thinks the colour should be given your current location. Note that f.lux has much more aggressive reddening, so default redshift will seem mild if you don’t customise it.
- some way to convert the colour temperature into a hex colour value. Unfortunately this is rather an art, because although you can compute the actual colour that a black body will radiate at, human vision is complicated and rather context dependent. I used a hacked version of this table which went in to
~/dotfiles/scripts/colormapping
.
With all that put together, the following bash monster asks redshift what colour temperature it should be right now given the current location, then looks that up in the colormapping file to get the hex color, and sends that to the hue. Run this every minute or so and you’ll get a nice fade.
redshift -l corelocation -t 5500:1900 -p | grep temp | cut -d: -f2 | xargs echo | grep -f /dev/stdin ~/dotfiles/scripts/colormapping | cut -d" " -f2 | tr -d "#" | xargs hue lights all
7
Kudos
7
Kudos