Extension: Remove color scheme settings
GNOME is built around the `default` and `prefer-dark` color schemes, adding `prefer-light` into the mix generates too much paper cuts. This could be reverted if GNOME add proper `prefer-light` integration.
This commit is contained in:
@@ -16,11 +16,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<value nick="teal" value="8"/>
|
<value nick="teal" value="8"/>
|
||||||
<value nick="yellow" value="9"/>
|
<value nick="yellow" value="9"/>
|
||||||
</enum>
|
</enum>
|
||||||
<enum id="org.gnome.shell.extensions.nightthemeswitcher.color-scheme-enum">
|
|
||||||
<value nick="default" value="0"/>
|
|
||||||
<value nick="prefer-dark" value="1"/>
|
|
||||||
<value nick="prefer-light" value="2"/>
|
|
||||||
</enum>
|
|
||||||
<schema id="org.gnome.shell.extensions.nightthemeswitcher" path="/org/gnome/shell/extensions/nightthemeswitcher/">
|
<schema id="org.gnome.shell.extensions.nightthemeswitcher" path="/org/gnome/shell/extensions/nightthemeswitcher/">
|
||||||
<key name="settings-version" type="i">
|
<key name="settings-version" type="i">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
@@ -76,14 +71,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<default>0</default>
|
<default>0</default>
|
||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
<schema id="org.gnome.shell.extensions.nightthemeswitcher.color-scheme" path="/org/gnome/shell/extensions/nightthemeswitcher/color-scheme/">
|
|
||||||
<key name="day" enum="org.gnome.shell.extensions.nightthemeswitcher.color-scheme-enum">
|
|
||||||
<default>"default"</default>
|
|
||||||
</key>
|
|
||||||
<key name="night" enum="org.gnome.shell.extensions.nightthemeswitcher.color-scheme-enum">
|
|
||||||
<default>"prefer-dark"</default>
|
|
||||||
</key>
|
|
||||||
</schema>
|
|
||||||
<schema id="org.gnome.shell.extensions.nightthemeswitcher.accent-color" path="/org/gnome/shell/extensions/nightthemeswitcher/accent-color/">
|
<schema id="org.gnome.shell.extensions.nightthemeswitcher.accent-color" path="/org/gnome/shell/extensions/nightthemeswitcher/accent-color/">
|
||||||
<key name="day" enum="org.gnome.shell.extensions.nightthemeswitcher.accent-color-enum">
|
<key name="day" enum="org.gnome.shell.extensions.nightthemeswitcher.accent-color-enum">
|
||||||
<default>"unset"</default>
|
<default>"unset"</default>
|
||||||
|
|||||||
@@ -26,39 +26,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPreferencesGroup">
|
<object class="AdwPreferencesGroup">
|
||||||
<child>
|
|
||||||
<object class="AdwActionRow">
|
|
||||||
<property name="title" translatable="yes">Style</property>
|
|
||||||
<child>
|
|
||||||
<object class="AdwToggleGroup">
|
|
||||||
<style>
|
|
||||||
<class name="flat"/>
|
|
||||||
<class name="round"/>
|
|
||||||
</style>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<property name="active-name" bind-source="AppearanceChooser" bind-property="color-scheme" bind-flags="bidirectional"/>
|
|
||||||
<child>
|
|
||||||
<object class="AdwToggle">
|
|
||||||
<property name="name">prefer-light</property>
|
|
||||||
<property name="label" translatable="yes">Light</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="AdwToggle">
|
|
||||||
<property name="name">default</property>
|
|
||||||
<property name="label" translatable="yes">Default</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="AdwToggle">
|
|
||||||
<property name="name">prefer-dark</property>
|
|
||||||
<property name="label" translatable="yes">Dark</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwActionRow">
|
<object class="AdwActionRow">
|
||||||
<property name="title" translatable="yes">Accent color</property>
|
<property name="title" translatable="yes">Accent color</property>
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<property name="name">day</property>
|
<property name="name">day</property>
|
||||||
<property name="title" translatable="yes">Day</property>
|
<property name="title" translatable="yes">Day</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="AppearanceChooser" id="day_appearance_chooser"/>
|
<object class="AppearanceChooser" id="day_appearance_chooser">
|
||||||
|
<property name="color-scheme">default</property>
|
||||||
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@@ -36,7 +38,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<property name="name">night</property>
|
<property name="name">night</property>
|
||||||
<property name="title" translatable="yes">Night</property>
|
<property name="title" translatable="yes">Night</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="AppearanceChooser" id="night_appearance_chooser"/>
|
<object class="AppearanceChooser" id="night_appearance_chooser">
|
||||||
|
<property name="color-scheme">prefer-dark</property>
|
||||||
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { Switcher } from "./Switcher.js";
|
|||||||
* The Color Scheme Switcher changes the system color scheme according to the time.
|
* The Color Scheme Switcher changes the system color scheme according to the time.
|
||||||
*/
|
*/
|
||||||
export class ColorSchemeSwitcher extends Switcher {
|
export class ColorSchemeSwitcher extends Switcher {
|
||||||
#settings;
|
|
||||||
#interfaceSettings;
|
#interfaceSettings;
|
||||||
#timer;
|
#timer;
|
||||||
|
|
||||||
@@ -25,15 +24,12 @@ export class ColorSchemeSwitcher extends Switcher {
|
|||||||
* @param {import("./Timer.js").Timer} params.timer Timer to listen to.
|
* @param {import("./Timer.js").Timer} params.timer Timer to listen to.
|
||||||
*/
|
*/
|
||||||
constructor({ timer }) {
|
constructor({ timer }) {
|
||||||
const settings = NTS.getSettings(`${NTS.metadata["settings-schema"]}.color-scheme`);
|
|
||||||
super({
|
super({
|
||||||
name: "Color Scheme",
|
name: "Color Scheme",
|
||||||
timer,
|
timer,
|
||||||
settings,
|
|
||||||
callback: (time) => this.#onTimeChanged(time),
|
callback: (time) => this.#onTimeChanged(time),
|
||||||
});
|
});
|
||||||
this.#timer = timer;
|
this.#timer = timer;
|
||||||
this.#settings = settings;
|
|
||||||
this.#interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
this.#interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,14 +45,6 @@ export class ColorSchemeSwitcher extends Switcher {
|
|||||||
|
|
||||||
#connectSettings() {
|
#connectSettings() {
|
||||||
debug.message("Connecting Color Scheme Switcher to settings...");
|
debug.message("Connecting Color Scheme Switcher to settings...");
|
||||||
this.#settingsConnections.push({
|
|
||||||
settings: this.#settings,
|
|
||||||
id: this.#settings.connect("changed::day", this.#onColorSchemeChanged.bind(this)),
|
|
||||||
});
|
|
||||||
this.#settingsConnections.push({
|
|
||||||
settings: this.#settings,
|
|
||||||
id: this.#settings.connect("changed::night", this.#onColorSchemeChanged.bind(this)),
|
|
||||||
});
|
|
||||||
this.#settingsConnections.push({
|
this.#settingsConnections.push({
|
||||||
settings: this.#interfaceSettings,
|
settings: this.#interfaceSettings,
|
||||||
id: this.#interfaceSettings.connect("changed::color-scheme", this.#onSystemColorSchemeChanged.bind(this)),
|
id: this.#interfaceSettings.connect("changed::color-scheme", this.#onSystemColorSchemeChanged.bind(this)),
|
||||||
@@ -70,16 +58,10 @@ export class ColorSchemeSwitcher extends Switcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#onTimeChanged(time) {
|
#onTimeChanged(time) {
|
||||||
const colorScheme = time === Time.NIGHT ? this.#settings.get_string("night") : this.#settings.get_string("day");
|
const colorScheme = time === Time.NIGHT ? ColorScheme.PREFER_DARK : ColorScheme.DEFAULT;
|
||||||
this.#interfaceSettings.set_string("color-scheme", colorScheme);
|
this.#interfaceSettings.set_string("color-scheme", colorScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
#onColorSchemeChanged(_settings, time) {
|
|
||||||
const colorScheme = this.#settings.get_string(time);
|
|
||||||
debug.message(`${time} color scheme changed to ${colorScheme}.`);
|
|
||||||
if (time === this.#timer.time) this.#interfaceSettings.set_string("color-scheme", colorScheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
#onSystemColorSchemeChanged() {
|
#onSystemColorSchemeChanged() {
|
||||||
const systemColorScheme = this.#interfaceSettings.get_string("color-scheme");
|
const systemColorScheme = this.#interfaceSettings.get_string("color-scheme");
|
||||||
const time = systemColorScheme === ColorScheme.PREFER_DARK ? Time.NIGHT : Time.DAY;
|
const time = systemColorScheme === ColorScheme.PREFER_DARK ? Time.NIGHT : Time.DAY;
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ export class Switcher {
|
|||||||
* @param {object} params Params object.
|
* @param {object} params Params object.
|
||||||
* @param {string} params.name Name of the switcher.
|
* @param {string} params.name Name of the switcher.
|
||||||
* @param {import("./Timer.js").Timer} params.timer Timer to listen to.
|
* @param {import("./Timer.js").Timer} params.timer Timer to listen to.
|
||||||
* @param {import("gi://Gio").default.Settings} params.settings Settings.
|
* @param {?import("gi://Gio").default.Settings} params.settings Settings.
|
||||||
* @param {TimeChangedCallback} params.callback Callback function.
|
* @param {TimeChangedCallback} params.callback Callback function.
|
||||||
* @param {boolean} params.disableable If the switcher can be disabled using an `enabled` key in the settings.
|
* @param {boolean} params.disableable If the switcher can be disabled using an `enabled` key in the settings.
|
||||||
*/
|
*/
|
||||||
constructor({ name, timer, settings, callback, disableable = false }) {
|
constructor({ name, timer, settings = null, callback, disableable = false }) {
|
||||||
this.#name = name;
|
this.#name = name;
|
||||||
this.#timer = timer;
|
this.#timer = timer;
|
||||||
this.#settings = settings;
|
this.#settings = settings;
|
||||||
@@ -41,6 +41,8 @@ export class Switcher {
|
|||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
debug.message(`Enabling ${this.#name} switcher...`);
|
debug.message(`Enabling ${this.#name} switcher...`);
|
||||||
|
if (this.#disableable && !this.#settings)
|
||||||
|
throw new Error(`${this.#name} Switcher can't be disabled without settings.`);
|
||||||
if (this.#disableable) this.#watchStatus();
|
if (this.#disableable) this.#watchStatus();
|
||||||
if (!this.#disableable || this.#settings.get_boolean("enabled")) {
|
if (!this.#disableable || this.#settings.get_boolean("enabled")) {
|
||||||
this.#connectTimer();
|
this.#connectTimer();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class AppearancePage extends Adw.PreferencesPage {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor({ accentColorSettings, colorSchemeSettings, ...params } = {}) {
|
constructor({ accentColorSettings, ...params } = {}) {
|
||||||
super(params);
|
super(params);
|
||||||
const backgroundSettings = new Gio.Settings({ schema: "org.gnome.desktop.background" });
|
const backgroundSettings = new Gio.Settings({ schema: "org.gnome.desktop.background" });
|
||||||
const interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
const interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
||||||
@@ -30,9 +30,6 @@ export class AppearancePage extends Adw.PreferencesPage {
|
|||||||
accentColorSettings.bind("day", this._day_appearance_chooser, "accent-color", Gio.SettingsBindFlags.DEFAULT);
|
accentColorSettings.bind("day", this._day_appearance_chooser, "accent-color", Gio.SettingsBindFlags.DEFAULT);
|
||||||
accentColorSettings.bind("night", this._night_appearance_chooser, "accent-color", Gio.SettingsBindFlags.DEFAULT);
|
accentColorSettings.bind("night", this._night_appearance_chooser, "accent-color", Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
colorSchemeSettings.bind("day", this._day_appearance_chooser, "color-scheme", Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
colorSchemeSettings.bind("night", this._night_appearance_chooser, "color-scheme", Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
|
|
||||||
backgroundSettings.bind(
|
backgroundSettings.bind(
|
||||||
"picture-uri",
|
"picture-uri",
|
||||||
this._day_appearance_chooser,
|
this._day_appearance_chooser,
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ export default class NightThemeSwitcherPreferences extends ExtensionPreferences
|
|||||||
[
|
[
|
||||||
new AppearancePage({
|
new AppearancePage({
|
||||||
accentColorSettings: this.getSettings(`${this.metadata["settings-schema"]}.accent-color`),
|
accentColorSettings: this.getSettings(`${this.metadata["settings-schema"]}.accent-color`),
|
||||||
colorSchemeSettings: this.getSettings(`${this.metadata["settings-schema"]}.color-scheme`),
|
|
||||||
}),
|
}),
|
||||||
new CommandsPage({ settings: this.getSettings(`${this.metadata["settings-schema"]}.commands`) }),
|
new CommandsPage({ settings: this.getSettings(`${this.metadata["settings-schema"]}.commands`) }),
|
||||||
new TweaksPage({
|
new TweaksPage({
|
||||||
|
|||||||
Reference in New Issue
Block a user