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

fix disable resetting color+temp continuously #719

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 16 additions & 7 deletions src/redshift.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ run_continual_mode(const location_provider_t *provider,
int prev_disabled = 1;
int disabled = 0;
int location_available = 1;
int should_reset = 0;
while (1) {
/* Check to see if disable signal was caught */
if (disable && !done) {
Expand All @@ -685,6 +686,7 @@ run_continual_mode(const location_provider_t *provider,
if (verbose && disabled != prev_disabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This conditional is wrong, see https://gitlab.com/chinstrap/gammastep/-/issues/2

printf(_("Status: %s\n"), disabled ?
_("Disabled") : _("Enabled"));
should_reset = 1;
}

prev_disabled = disabled;
Expand Down Expand Up @@ -724,7 +726,9 @@ run_continual_mode(const location_provider_t *provider,

if (disabled) {
period = PERIOD_NONE;
color_setting_reset(&target_interp);
if (should_reset) {
color_setting_reset(&target_interp);
}
}

if (done) {
Expand Down Expand Up @@ -797,18 +801,23 @@ run_continual_mode(const location_provider_t *provider,
}

/* Adjust temperature */
r = method->set_temperature(
method_state, &interp, preserve_gamma);
if (r < 0) {
fputs(_("Temperature adjustment failed.\n"),
stderr);
return -1;
if (!disabled || should_reset) {
r = method->set_temperature(
method_state, &interp, preserve_gamma);
if (r < 0) {
fputs(_("Temperature adjustment failed.\n"),
stderr);
return -1;
}
}

/* Save period and target color setting as previous */
prev_period = period;
prev_target_interp = target_interp;

/* All resets have been done now */
should_reset = 0;

/* Sleep length depends on whether a fade is ongoing. */
int delay = SLEEP_DURATION;
if (fade_length != 0) {
Expand Down