Matthew Graybosch
a cynical idealist, sf author, and full-stack developer

blueshift

blueshift is a replacement for redshift built with POSIX shell, core utilities, and sct that I developed and tested on OpenBSD. It’s available for any OS that also supports sct under the 2-clause BSD license.

contents

download

blueshift is developed on Sourcehut. I wrote it to scratch my itch, but if it doesn’t quite scratch yours feel free to improve upon it.

You can also download blueshift here. I’ll try to keep versions synced between this site and Sourcehut, but Sourcehut is the primary source.

dependencies

  • a working BSD or GNU/Linux system
  • a working X11 setup
  • a POSIX-compliant /bin/sh
  • sct

use case

You should consider using blueshift if you want to run a periodic cron job and/or a acpi wakeup script (like /etc/apm/resume) to check the current time, compare it against a set of “sunrise” and “sunset” times, and set your display’s color temperature to a reasonable value to help reduce eyestrain.

Because blueshift doesn’t run as a daemon, it may be a better fit for laptop users since you can control how often it runs to check the time.

You can also do this with greater precision using redshift, but that app is heavier in terms of dependencies. It also requires a set of ICBM targeting coordinates (latitude/longitude) or permission to geolocate your external IP address.

alternatives

If you’re on OpenBSD, you may not know that the sct package also comes with a script called sctd by Aaron Bieber which works as a daemon and provides a transition over time.

installation instructions

At the moment, you’ll need to manually install blueshift by copying it to convenient location in your $PATH. I suggest ${HOME}/bin.

usage instructions

Run blueshift with four arguments.

  1. sunrise time in 24-hour format (military time)
  2. sunset time in 24-hour format (military time)
  3. daytime color temperature (in degrees Kelvin)
  4. nighttime color temperature (in degrees Kelvin)

The script will make the following sanity checks:

  1. all arguments have been provided
  2. sct is installed and executable
  3. sunrise and sunset times are between 0000 and 2359
  4. sunset time is greater than sunrise time
  5. color temperature values are between 0 and 10,000

If everything looks good, blueshift will get the current time from your system clock, compare it against the sunrise and sunset times, and run sct with the appropriate color temperature value.

example

To set daytime color temperature to 6500K at 6am, and nighttime color temperature to 4500K at 6pm.

$ blueshift 0600 1800 6500 4500

caveats

  • The color temperature change is abrupt; I haven’t bothered to implement a transition over time.
  • It is possible to run blueshift with a nighttime color temperature that’s greater than the daytime color temperature. The script will check for this and issue a warning, but you can still do this if you want to. I figure that you know what you’re doing and have your reasons.

todo

  • [DONE] I really should verify that X11 is running as part of the initial diagnostics.
  • Write a proper manual page
  • Create a port for OpenBSD so it can be installed through the package mangler.

credits

  • Ted Unangst for sct
  • Smudge and Purrseus for moral support
  • Catherine Gatt for putting up with me tinkering instead of writing