Skip to content

Commit d5f4285

Browse files
authored
nightlight: Implement schedule mode 'always' (#408)
This is more user-friendly than having to tweak the start and stop times.
1 parent 9b7fd68 commit d5f4285

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

data/org.cinnamon.settings-daemon.plugins.color.gschema.xml.in.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<enum id="schedule_mode">
33
<value value="0" nick="auto"/>
44
<value value="1" nick="manual"/>
5+
<value value="2" nick="always"/>
56
</enum>
67
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.cinnamon.settings-daemon.plugins.color" path="/org/cinnamon/settings-daemon/plugins/color/">
78
<key name="recalibrate-display-threshold" type="u">
@@ -27,7 +28,7 @@
2728
<key name="night-light-schedule-mode" enum="schedule_mode">
2829
<default>'auto'</default>
2930
<summary>Set the way start and stop times are determined</summary>
30-
<description>Setting to 'auto' will use the system timezone to determine sunrise and sunset. Using 'manual' mode allows specifying exact start and stop times (night-light-schedule-from and -to).</description>
31+
<description>Setting to 'auto' will use the system timezone to determine sunrise and sunset. Using 'manual' mode allows specifying exact start and stop times (night-light-schedule-from and -to). The 'always' mode keeps the selected color temperature of your display permanently on.</description>
3132
</key>
3233
<key name="night-light-schedule-from" type="d">
3334
<default>20.00</default>

plugins/color/csd-night-light.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ enum {
6262

6363
enum {
6464
NIGHT_LIGHT_SCHEDULE_AUTO = 0,
65-
NIGHT_LIGHT_SCHEDULE_MANUAL = 1
65+
NIGHT_LIGHT_SCHEDULE_MANUAL = 1,
66+
NIGHT_LIGHT_SCHEDULE_ALWAYS_ON = 2
6667
};
6768

6869
#define CSD_NIGHT_LIGHT_SCHEDULE_TIMEOUT 5 /* seconds */
@@ -274,13 +275,26 @@ night_light_recheck (CsdNightLight *self)
274275
return;
275276
}
276277

277-
/* calculate the position of the sun */
278-
if (g_settings_get_enum (self->settings, "night-light-schedule-mode") == NIGHT_LIGHT_SCHEDULE_AUTO) {
278+
/* schedule-mode */
279+
switch (g_settings_get_enum (self->settings, "night-light-schedule-mode")) {
280+
case NIGHT_LIGHT_SCHEDULE_ALWAYS_ON:
281+
/* just set the temperature to night light */
282+
temperature = g_settings_get_uint (self->settings, "night-light-temperature");
283+
g_debug ("night light mode always on, using temperature of %uK",
284+
temperature);
285+
csd_night_light_set_active (self, TRUE);
286+
csd_night_light_set_temperature (self, temperature);
287+
return;
288+
case NIGHT_LIGHT_SCHEDULE_AUTO:
289+
/* calculate the position of the sun */
279290
update_cached_sunrise_sunset (self);
280291
if (self->cached_sunrise > 0.f && self->cached_sunset > 0.f) {
281292
schedule_to = self->cached_sunrise;
282293
schedule_from = self->cached_sunset;
283294
}
295+
break;
296+
default:
297+
break;
284298
}
285299

286300
/* fall back to manual settings */

0 commit comments

Comments
 (0)