Commit Graph
129 Commits
Author SHA1 Message Date
Jon Lund Steffensen e075444663 Change preserve option to command line switch
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.
2017-10-13 19:08:57 -07:00
Jon Lund Steffensen 55455f99d9 Add function for resetting color_setting_t 2017-10-13 18:12:44 -07:00
Jon Lund Steffensen 3e0fef4e8d Move options handling to separate file
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.
2017-10-13 18:12:44 -07:00
Jon Lund Steffensen b27acd6878 Allocate module data in init functions 2017-10-13 18:09:28 -07:00
Jon Lund Steffensen 6531b8c73d Move module struct definitions to separate files 2017-10-13 17:53:58 -07:00
Jon Lund Steffensen 86bb509eca Fix bug where error code was not handled 2017-10-12 14:01:28 -07:00
Jon Lund Steffensen 64600ae55d Fix missing checks and verbose output
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.
2017-10-12 12:36:39 -07:00
Jon Lund Steffensen 1e425c66f5 Time-based configuration
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>.
2017-10-11 14:45:59 -07:00
Jon Lund Steffensen d8f04b9020 redshift: Improve fade implementation
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.
2017-08-30 17:12:56 -07:00
Jon Lund Steffensen 8165badbc2 Change term transition to fade
Use the term "fade" instead of "transition" for the short (~5s)
fade between color temperatures. The term "transition" is now only
used for the transition phase between daytime and night.

The setting "transition" in the configuration file is now deprecated
and "fade" should be used instead.
2017-08-30 15:21:43 -07:00
Jon Lund Steffensen 00e2d538e8 geoclue2: Update continuously 2017-08-17 20:24:32 -07:00
Jon Lund Steffensen df10508e30 corelocation: Update continuously 2017-08-17 20:24:32 -07:00
Jon Lund Steffensen 153dec0e21 Change location providers to allow updates
Change location provider implementations so it is possible for
location providers to dynamically update the location. This
commit adds the interfaces and infrastructure in redshift.c
but none of the location provides are changed to become dynamic.
2017-08-17 19:52:29 -07:00
Jon Lund Steffensen 4adb93a448 Remove deprecated geoclue 1 location provider 2017-08-16 20:46:53 -07:00
Faheel Ahmad 6d44559b48 Limit lines to 80 chars 2017-07-29 16:36:27 +05:30
Faheel Ahmad 29727a990c Fix #474: Format help text paragraph to 80 chars max 2017-07-27 08:58:22 +05:30
Jon Lund Steffensen d7b7caf990 redshift.c: Use 6500K and 4500K by default 2017-01-08 15:44:58 -05:00
Mattias Andrée e0a617fcad Move signal processing functions and sigaction calls to signals from redshift.c
Signed-off-by: Mattias Andrée <maandree@operamail.com>
2015-12-28 11:31:42 -05:00
Jon Lund Steffensen 5f26b3d396 Merge pull request #197 from forivall/clamp-fix
Fix clamp issues
2015-05-10 20:34:47 -04:00
Mattias Andrée 6954f21fd4 remove unnecessary null-checks, it is safe to pass NULL to free (per documentation)
Signed-off-by: Mattias Andrée <maandree@operamail.com>
2015-05-07 17:52:27 +02:00
Jordan Klassen ba15832b9e Fix CLAMP macro overwritten by glib headers
Fixes #188

When I moved the macro definition below all of the includes, I got the
following compiler warning:

/usr/include/glib-2.0/glib/gmacros.h:246:0: note: this is the location
of the previous definition
 #define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low))
? (low) : (x)))

So, that's the macro definition that was being used whenever "CLAMP" was
used. It's pretty obvious what went wrong.
2015-05-02 12:35:05 -07:00
Jon Lund Steffensen 731a7d2cd5 Fix #162: Ensure that interpolation alpha is in [0;1] 2015-01-15 09:37:31 -05:00
Christian Burger 8dbeda906a fixes jonls/redshift#157 introduced by jonls/redshift@f9c2a1568c 2015-01-10 12:32:04 +01:00
Jon Lund Steffensen 8d5cf30b4d redshift: Add print_location() function 2015-01-04 17:48:10 -05:00
Jon Lund Steffensen 017fc230be redshift: Add gamma_is_valid function to check gamma
This checks whether the gamma values are within the bounds of
MIN_GAMMA and MAX_GAMMA.
2015-01-04 16:32:47 -05:00
Jon Lund Steffensen bb61a25e88 redshift: Add transition scheme type with color settings
This changes the transition_levels_t to transition_scheme_t and
adds two fields day, night of type color_setting_t. This
encapsulates all the information needed to calculate the current
color setting from an elevation.
2015-01-04 16:32:47 -05:00
Jon Lund Steffensen c2f0ca4647 redshift: Make transition levels parameter to related functions
Moves transition_low and transition_high from globals into a
struct transition_levels_t that is created in main and passed to
the relevant functions.
2015-01-04 16:32:47 -05:00
Jon Lund Steffensen f9c2a1568c redshift: Move continual loop mode to separate function 2015-01-04 16:32:47 -05:00
Jon Lund Steffensen 799b08214d Add location_t type with lat/lon fields 2015-01-04 16:32:47 -05:00
Jon Lund Steffensen 0cc785c730 redshift: Add noop pause() macro on windows platform
Build failed on windows platform since pause() is not available. The
function is not needed on the windows platform so we just define a
noop pause() macro.
2015-01-04 14:53:16 -05:00
Jon Lund Steffensen bd086885a5 Fix #152: redshift: Loop in reset/manual/one-shot mode with Quartz
The gamma adjustments made with the Quartz (OSX) method are tied
to the process so when we exit, the gamma adjustments are reset.
Therefore we need to run a loop that breaks on CTRL-C, after the
gamma adjustments are made.
2015-01-04 13:50:53 -05:00
Jon Lund Steffensen 542254705b redshift: Fix untranslated status strings 2014-12-30 22:08:06 -05:00
Jon Lund Steffensen 59023d86f4 Merge branch 'hooks-dir' 2014-12-28 19:26:29 -05:00
Jon Lund Steffensen f154aaa7c1 redshift: Add translation comment on period name None 2014-12-28 14:34:43 -05:00
Jon Lund Steffensen 0b94ec26fe redshift: Add translation of Daytime/Night in new gamma string 2014-12-28 14:34:21 -05:00
Jon Lund Steffensen d281e0c1ed redshift: Add translation comment to N,S,W,E strings 2014-12-28 14:33:11 -05:00
Jon Lund Steffensen ba422bd78e systemtime: Add function wrapping platform sleep function
Adds systemtime_msleep() which sleeps for a number of milliseconds.
This wraps Sleep() on windows and usleep() on other platforms.
2014-12-28 13:13:21 -05:00
Jon Lund Steffensen 159754c1cd redshift: Add hooks for user actions on period switch
Hooks are executable scripts in ~/.config/redshift/hooks/ that
are run when a certain event happens. The first parameter to the
script indicates the event and further parameters may indicate
more details about the event.

The event "period-changed" is indicated when the period changes
("night", "daytime", "transition"). The second parameter is the old
period and the third is the new period. The event is signaled when
Redshift starts up with the old period set to "none".
2014-12-28 01:36:26 -05:00
Jon Lund Steffensen 4a572e85e9 redshift: Move period_t to header 2014-12-28 01:30:35 -05:00
Jon Lund Steffensen d58de55645 redshift: Add enum member for unknown period_t (PERIOD_NONE) 2014-12-28 01:25:10 -05:00
Jon Lund Steffensen 4e7717cf14 redshift: Properly handle errors in sigaction 2014-12-28 01:23:30 -05:00
Jon Lund Steffensen cfe90ccf70 redshift: Fix translation of period names
The static string array period_names contains strings that are printed
but these were not marked for translation. This is fixed now by adding
the _N() macro and calling gettext() when the strings are used.
2014-12-27 23:12:47 -05:00
Jon Lund Steffensen 396ecd69a8 redshift: Only print period information when it changes
This change adds functions to determine what the current period is
so we can keep track and only print the period when it changes.
2014-12-27 21:27:36 -05:00
Jon Lund Steffensen 431780b851 redshift: Be less verbose when color values did not change
This keeps a copy of the previous color_setting_t in the loop so
that we can avoid printing the color temperature and brightness if
they did not change.
2014-12-27 21:26:37 -05:00
Jon Lund Steffensen 6ecbfe324f redshift: Change duration of sleep to macro 2014-12-27 20:46:59 -05:00
Jon Lund Steffensen ec5aa19acf redshift: Simplify set_temperature by passing color_setting_t
Changes all set_temperature function in gamma adjustment methods
to take a color_setting_t pointer with the color settings.

Colorramp functions are similarly changed to take a color settings
struct.
2014-12-27 20:22:11 -05:00
Jon Lund Steffensen a4052e2a7b redshift: Add config setting to set gamma separately for day/night
These settings are gamma-day and gamma-night. The setting gamma
will still override both the daytime and nighttime gamma setting.
2014-12-27 19:43:05 -05:00
Jon Lund Steffensen 4ac4d9ee2d redshift: Move color settings into struct for period
Move color settings (temperature, gamma and brightness) into a
struct for each period (day, night). Change the interpolation
function to interpolate all values between these structs.
2014-12-27 19:43:05 -05:00
Jon Lund Steffensen c00bcff953 redshift: Use double for interpolation function 2014-12-27 19:30:16 -05:00
Jon Lund Steffensen 8839dcd530 Add CoreLocation (OSX) location provider
Similarly to the Geoclue provider, the CoreLocation provider only
requests the location on startup.
2014-12-15 20:36:35 -05:00