Redshift

Intro

Redshift is a program similar to f.lux, which changes your color palate to reduce blue light output at night. This is reported to help with insomnia caused by exposure to electronic devices at night.

How this works

This script calls from dom0 through to sys-net, to determine your latitude and longitude. It then uses those variables to create the redshift.sh script (inside ~/.config), which will then run redshift properly. This is required because redshift needs to know your (approximate) lat/long in order to approximate sunset and so to determine what colors to use. It goes without saying then, that you need to rerun this script whenever you move.

Caveat

This script stores your (approximate) lat/long inside a file in dom0. Dom0 is generally considered to be part of the trusted computing base. As such, storing this information doesn't help an attacker who can compromise dom0 (through a xen 0day, etc). In the event of another meltdown style attack, however, whereby a vm can break the hardware memory protection model and read the ram of arbitrary dom0 processes, this could be an information leak. This would only be the case if a VPN or Tor was being used, as otherwise the information would generally be accessible to an attacker in the form of a geoip lookup.

Script

The main script, update-redshift.sh.

   1 #!/bin/bash
   2 LATLON=`qvm-run --pass-io sys-net 'wget -qO- ip-api.com/line?fields=lat,lon' | cut -d '.' -f 1 | tr '\n' ' ' | tr -dc '[:digit:] [:punct:]' | awk '{print $1 ":" $2}'`
   3 REDSHIFT_OPTS=
   4 
   5 if [ -f /etc/redshift.conf ]; then
   6         . /etc/redshift.conf
   7 fi
   8 
   9 echo "#!/bin/bash" > ~/.config/redshift.sh
  10 echo "redshift -l $LATLON $REDSHIFT_OPTS" >> ~/.config/redshift.sh
  11 chmod +x ~/.config/redshift.sh

Then add

~/.config/redshift.sh &

to your screens_post.sh if you are using the screen autosetup scripts.

Or add

#Start redshift on startup
exec --no-startup-id "~/.config/redshift.sh &"

to your ~.config/i3/config if you are using raw i3.

HowTo/Redshift (last edited 2018-12-02 11:59:35 by admin)