Skip to content

Commit f3fa69a

Browse files
committed
Added support for brightness config to extension
1 parent 461fa5a commit f3fa69a

File tree

5 files changed

+70
-9
lines changed

5 files changed

+70
-9
lines changed

[email protected]/extension.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ const Redshift = new Lang.Class({
132132

133133
this._color_settings.set_int("color-temperature", temp);
134134

135+
let night_brt = this._settings.get_double(Lib.NIGHT_BRT_KEY);
136+
let day_brt = this._settings.get_double(Lib.DAY_BRT_KEY);
137+
138+
let brt = night_brt * (1 - night_day) + day_brt * night_day;
139+
140+
this._color_settings.set_double("color-brightness", brt);
141+
135142
if (enabled) {
136143
if (night_day < 0.1) {
137144
this._icon.icon_name = "my-redshift-moon-symbolic";

[email protected]/lib.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const SHOW_INDICATOR_KEY = 'show-indicator';
2222
const STATE_KEY = 'state';
2323
const NIGHT_TEMP_KEY = 'night-color-temperature';
2424
const DAY_TEMP_KEY = 'day-color-temperature';
25+
const NIGHT_BRT_KEY = 'night-brightness'
26+
const DAY_BRT_KEY = 'day-brightness'
2527
const NIGHT_DAY_KEY = 'night-day';
2628
const DUSK_DAWN_LENGTH_KEY = 'dusk-dawn-length';
2729

[email protected]/locale/messages.pot

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ msgstr ""
4141
msgid "Nighttime color temperature (e.g.: 2750K)"
4242
msgstr ""
4343

44-
#: prefs.js:75
44+
#: prefs.js:76
45+
msgid "Daytime brightness (full: 1.0)"
46+
msgstr ""
47+
48+
#: prefs.js:91
49+
msgid "Nighttime brightness (e.g.: 0.5)"
50+
msgstr ""
51+
52+
#: prefs.js:107
4553
msgid "Length of the dusk/dawn progression in minutes"
4654
msgstr ""

[email protected]/prefs.js

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,38 @@ const RedshiftWidget = new Lang.Class({
7272
this.w.attach(label, 0, 3, 1, 1);
7373
this.w.attach(temp, 1, 3, 1, 1);
7474

75+
76+
let label = new Gtk.Label({label: _("Daytime brightness (full: 1.0)"),
77+
xalign: 0});
78+
79+
let temp = new Gtk.SpinButton();
80+
temp.set_range(0.1, 1.0);
81+
temp.set_value(this._settings.get_double(Lib.DAY_BRT_KEY));
82+
temp.set_digits(1);
83+
temp.set_increments(0.1, 0.5);
84+
temp.connect('notify::value', Lang.bind(this, function(button) {
85+
this._settings.set_double(Lib.DAY_BRT_KEY, button.value);
86+
}));
87+
88+
this.w.attach(label, 0, 4, 1, 1);
89+
this.w.attach(temp, 1, 4, 1, 1);
90+
91+
let label = new Gtk.Label({label: _("Nighttime brightness (e.g.: 0.5)"),
92+
xalign: 0});
93+
94+
let temp = new Gtk.SpinButton();
95+
temp.set_range(0.1, 1.0);
96+
temp.set_value(this._settings.get_double(Lib.NIGHT_BRT_KEY));
97+
temp.set_digits(1);
98+
temp.set_increments(0.1, 0.5);
99+
temp.connect('notify::value', Lang.bind(this, function(button) {
100+
this._settings.set_double(Lib.NIGHT_BRT_KEY, button.value);
101+
}));
102+
103+
104+
this.w.attach(label, 0, 5, 1, 1);
105+
this.w.attach(temp, 1, 5, 1, 1);
106+
75107
let label = new Gtk.Label({label: _("Length of the dusk/dawn progression in minutes"),
76108
xalign: 0});
77109

@@ -84,8 +116,8 @@ const RedshiftWidget = new Lang.Class({
84116
this._settings.set_uint(Lib.DUSK_DAWN_LENGTH_KEY, Math.round(button.value));
85117
}));
86118

87-
this.w.attach(label, 0, 4, 1, 1);
88-
this.w.attach(length, 1, 4, 1, 1);
119+
this.w.attach(label, 0, 6, 1, 1);
120+
this.w.attach(length, 1, 6, 1, 1);
89121

90122

91123
let label = new Gtk.Label({label: _("Source of sunset/sunrise time:"),
@@ -102,8 +134,8 @@ const RedshiftWidget = new Lang.Class({
102134
this._settings.set_enum(Lib.TIME_SOURCE_KEY, id);
103135
}));
104136

105-
this.w.attach(label, 0, 5, 1, 1);
106-
this.w.attach(timesrc, 1, 5, 1, 1);
137+
this.w.attach(label, 0, 7, 1, 1);
138+
this.w.attach(timesrc, 1, 7, 1, 1);
107139

108140

109141
function format_time(time) {
@@ -142,8 +174,8 @@ const RedshiftWidget = new Lang.Class({
142174
}
143175
}));
144176

145-
this.w.attach(label, 0, 6, 1, 1);
146-
this.w.attach(time, 1, 6, 1, 1);
177+
this.w.attach(label, 0, 8, 1, 1);
178+
this.w.attach(time, 1, 8, 1, 1);
147179

148180

149181
let label = new Gtk.Label({label: _("Time of sunset in fixed mode (hh:mm):"),
@@ -161,8 +193,8 @@ const RedshiftWidget = new Lang.Class({
161193
}
162194
}));
163195

164-
this.w.attach(label, 0, 7, 1, 1);
165-
this.w.attach(time, 1, 7, 1, 1);
196+
this.w.attach(label, 0, 9, 1, 1);
197+
this.w.attach(time, 1, 9, 1, 1);
166198

167199
},
168200

[email protected]/schemas/org.gnome.shell.extensions.redshift-gnome.gschema.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,17 @@
6969
<summary>Fixed time of sunset (seconds after midnight)</summary>
7070
<description>The time of the simulated sunset when in fixed time mode. The setting is given as seconds after midnight.</description>
7171
</key>
72+
<key type="d" name="day-brightness">
73+
<default>1.0</default>
74+
<range min="0.0" max="1.0" />
75+
<summary>The displays brightness by day</summary>
76+
<description>The displays brightness by day. The default is 1.0.</description>
77+
</key>
78+
<key type="d" name="night-brightness">
79+
<default>1.0</default>
80+
<range min="0.0" max="1.0" />
81+
<summary>The displays brightness by night</summary>
82+
<description></description>
83+
</key>
7284
</schema>
7385
</schemalist>

0 commit comments

Comments
 (0)