diff --git a/extensions/light-style/extension.js b/extensions/light-style/extension.js new file mode 100644 index 00000000..9aaea481 --- /dev/null +++ b/extensions/light-style/extension.js @@ -0,0 +1,45 @@ +/* exported init */ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +const {St} = imports.gi; + +const Main = imports.ui.main; + +class Extension { + constructor() { + this._savedColorScheme = Main.sessionMode.colorScheme; + } + + _updateColorScheme(scheme) { + Main.sessionMode.colorScheme = scheme; + St.Settings.get().notify('color-scheme'); + } + + enable() { + this._updateColorScheme('prefer-light'); + } + + disable() { + this._updateColorScheme(this._savedColorScheme); + } +} + +/** */ +function init() { + return new Extension(); +} diff --git a/extensions/light-style/meson.build b/extensions/light-style/meson.build new file mode 100644 index 00000000..48504f63 --- /dev/null +++ b/extensions/light-style/meson.build @@ -0,0 +1,5 @@ +extension_data += configure_file( + input: metadata_name + '.in', + output: metadata_name, + configuration: metadata_conf +) diff --git a/extensions/light-style/metadata.json.in b/extensions/light-style/metadata.json.in new file mode 100644 index 00000000..a763a9f9 --- /dev/null +++ b/extensions/light-style/metadata.json.in @@ -0,0 +1,10 @@ +{ +"extension-id": "@extension_id@", +"uuid": "@uuid@", +"settings-schema": "@gschemaname@", +"gettext-domain": "@gettext_domain@", +"name": "Light Style", +"description": "Switch default to light style", +"shell-version": [ "@shell_current@" ], +"url": "@url@" +} diff --git a/meson.build b/meson.build index 2eda9e7d..d7a5dff0 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,7 @@ classic_extensions = [ default_extensions = classic_extensions default_extensions += [ 'drive-menu', + 'light-style', 'screenshot-window-sizer', 'windowsNavigator', 'workspace-indicator'