Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to adjust fade duration (with Elektra) #1

Open
wants to merge 7 commits into
base: improve-config/elektrify
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 fade duration (for fading between color temperatures) in full seconds.

Choose a reason for hiding this comment

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

Suggested change
description = Set fade duration (for fading between color temperatures) in full seconds.
description = Set length of the fade duration in full seconds for fading between color temperatures.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, this is easier to understand, thank you!

Copy link
Owner Author

Choose a reason for hiding this comment

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

Fixed.

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
3 changes: 3 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,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 @@ -398,6 +400,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 = PROGRAM_MODE_CONTINUAL;
options->verbose = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ typedef struct {
int temp_set;
/* Whether to fade between large skips in color temperature. */
int use_fade;
/* The length of the fade duration in seconds */

Choose a reason for hiding this comment

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

This should probably link to the spec "fade/duration" and not repeat the description?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, thanks for the hint!

Copy link
Owner Author

Choose a reason for hiding this comment

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

Fixed.

long fade_duration;
/* Whether to preserve gamma ramps if supported by gamma method. */
int preserve_gamma;

Expand Down
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 @@ -1204,7 +1206,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