Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/elektra/redshift.ni
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ opt = f
opt/long = fade-fast
opt/arg = none

[fade/duration]
type = unsigned_long
description = Set length of the fade duration in full seconds for fading between color temperatures.
default = 4
example = 5
opt/long = fade-duration
opt/arg = required

[brightness/day]
type = float
description = The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness.
Expand Down
23 changes: 13 additions & 10 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ static void
print_method_list(const gamma_method_t *gamma_methods)
{
if (gamma_methods[0].name == NULL) {
printf("This build of redshift contains no adjustment methods that work on your system!");
return;
printf("This build of redshift contains no adjustment methods that work on your system!");
return;
}

fputs(_("Available adjustment methods in this build of redshift:\n"), stdout);
Expand All @@ -112,8 +112,8 @@ static void
print_provider_list(const location_provider_t location_providers[])
{
if (location_providers[0].name == NULL) {
printf("This build of redshift contains no adjustment methods that work on your system!");
return;
printf("This build of redshift contains no adjustment methods that work on your system!");
return;
}

fputs(_("Available location providers in this build of redshift:\n"), stdout);
Expand Down Expand Up @@ -171,10 +171,10 @@ find_location_provider(
*/
int
options_load_from_elektra(
options_t *options,
Elektra *elektra,
const gamma_method_t *gamma_methods,
const location_provider_t *location_providers) {
options_t *options,
Elektra *elektra,
const gamma_method_t *gamma_methods,
const location_provider_t *location_providers) {
/**
* Before using Elektra, there were two sources for configuration: CLI options and config file.
* From redshift's point of view there is only one source now, namely Elektra.
Expand All @@ -189,8 +189,8 @@ options_load_from_elektra(

// Version
if (elektraGetVersion(elektra)) {
printf("%s\n", PACKAGE_STRING);
return -1;
printf("%s\n", PACKAGE_STRING);
return -1;
}

// Verbose
Expand Down Expand Up @@ -302,6 +302,8 @@ options_load_from_elektra(

// Fade
options->use_fade = !elektraGetFadeFast(elektra);

options->fade_duration = elektraGetFadeDuration(elektra);

// Temperature
options->scheme.day.temperature = elektraGetTempDay(elektra);
Expand Down Expand Up @@ -378,6 +380,7 @@ options_init(options_t *options)
options->provider = NULL;

options->use_fade = -1;
options->fade_duration = -1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed. I also adjusted CLion IDE to better detect existing indents in files.

options->preserve_gamma = 1;
options->mode = ELEKTRA_ENUM_MODE_CONTINUAL;
options->verbose = 0;
Expand Down
31 changes: 14 additions & 17 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,35 @@ typedef struct {
/* Path to config file */
char *config_filepath;

/*
* For description of these options, see Elektra specification file src/elektra/redshift.ni
*/
transition_scheme_t scheme;
ElektraEnumMode mode;
int verbose;

/* Temperature to set in manual mode. */
int temp_set;
/* Whether to fade between large skips in color temperature. */
int use_fade;
/* Whether to preserve gamma ramps if supported by gamma method. */
long fade_duration;
int preserve_gamma;

/* Selected gamma method. */

const gamma_method_t *method;
/* Options for adjustment methods */
unsigned short method_crtc;
unsigned short method_screen;
unsigned short method_drm_card;

/* Selected location provider. */
unsigned short method_crtc;
unsigned short method_screen;
unsigned short method_drm_card;

const location_provider_t *provider;
/* Lat, lon for location provider. */
float provider_manual_arg_lat;
float provider_manual_arg_lon;
float provider_manual_arg_lon;
} options_t;


int
options_load_from_elektra(
options_t *options,
Elektra *elektra,
const gamma_method_t *gamma_methods,
const location_provider_t *location_providers);
options_t *options,
Elektra *elektra,
const gamma_method_t *gamma_methods,
const location_provider_t *location_providers);
void options_init(options_t *options);

#endif /* ! REDSHIFT_OPTIONS_H */
11 changes: 7 additions & 4 deletions src/redshift.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ run_continual_mode(const location_provider_t *provider,
const transition_scheme_t *scheme,
const gamma_method_t *method,
gamma_state_t *method_state,
int use_fade, int preserve_gamma, int verbose)
int use_fade, long fade_duration,
int preserve_gamma, int verbose)
{
int r;

Expand Down Expand Up @@ -656,8 +657,9 @@ run_continual_mode(const location_provider_t *provider,
color_setting_diff_is_major(
&target_interp,
&prev_target_interp))) {
fade_length = FADE_LENGTH;
fade_time = 0;
// Scale fade_length according to desired fade_duration.
fade_length = (FADE_LENGTH * (fade_duration * 1000)) / (FADE_LENGTH * SLEEP_DURATION_SHORT);
fade_time = 0;
fade_start_interp = interp;
}
}
Expand Down Expand Up @@ -1172,7 +1174,8 @@ int main(int argc, const char * const *argv, const char * const *envp)
r = run_continual_mode(
options.provider, location_state, scheme,
options.method, method_state,
options.use_fade, options.preserve_gamma,
options.use_fade, options.fade_duration,
options.preserve_gamma,
options.verbose);
if (r < 0) exit(EXIT_FAILURE);
}
Expand Down