extensions: Add new light-style extension

Now that gnome-shell supports a light style, people may want to
use it without forcing all apps to be light.

Add a small extension that switches the default to light, so the
shell follows the regular "dark style" preference.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/256>
This commit is contained in:
Florian Müllner
2023-06-02 14:37:30 +02:00
committed by Marge Bot
parent 22b9f888fb
commit b7895ad956
4 changed files with 61 additions and 0 deletions
+45
View File
@@ -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 <http://www.gnu.org/licenses/>.
*
* 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();
}
+5
View File
@@ -0,0 +1,5 @@
extension_data += configure_file(
input: metadata_name + '.in',
output: metadata_name,
configuration: metadata_conf
)
+10
View File
@@ -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@"
}
+1
View File
@@ -37,6 +37,7 @@ classic_extensions = [
default_extensions = classic_extensions
default_extensions += [
'drive-menu',
'light-style',
'screenshot-window-sizer',
'windowsNavigator',
'workspace-indicator'