Changes each adjustment method to take a preserve parameter when
setting the temperature instead of parsing the preserve option
from the command line/configuration file. This helps resolve the
issues around #513:
- This allows the preserve option to be implemented as a
command-line switch (-P). This switch _disables_ the preservation
of existing gamma ramps. Having a command-line switch makes it
easier to use directly with manual or one-shot mode.
- The preserve options is on by default, so continual mode as well
as other modes will default to applying the color adjustment
on top of the current gamma ramps.
- Preserve is always disabled in reset mode so resetting works
as expected again.
Create options.c which contains functions for initializing and
parsing options from the command line and the configuration file.
Program options that were previously local variables in main() are
moved to the options_t struct.
The quartz (macOS) adjustment method incorrectly used the display
index instead of the associated CGDirectDisplayID. Incidentally this
happened to work too but was incorrect.
Rearrange checks and verbose output in main() to bring back checks
that were accidentally left out when time-based adjustments were
enabled. This includes the output indicating the daytime/night
temperatures and the check that the temperatures are valid.
Allow setting the time of the dawn and dusk transition periods
directly in the configuration file. If these are specified, the
location provider is not needed and is therefore not initialized.
Based on patch by Martin Nicolay <edelschimmel1@gmx.de>.
We have to retry SetDeviceGammaRamp a few times before giving up
because some buggy drivers fail on the first invocation just to
succeed on the second.
Simplify implementation of fades in continual mode. A fade is now
applied anytime the change in color temperature, brightness or
gamma is greater than a preset threshold. This means that a fade
is applied if the location provider suddenly updates to a new
location or if the currently time suddenly jumps e.g. after waking
up the computer from sleep. An easing function is applied to the
fade to make it more pleasant.