@@ -4,44 +4,6 @@ import Gio from 'gi://Gio';
44import * as Main from 'resource:///org/gnome/shell/ui/main.js' ;
55import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js' ;
66
7- const LIGHT_SCHEME_NAME = 'prefer-light' ;
8- const DARK_SCHEME_NAME = 'prefer-dark' ;
9-
10- const LIGHT_THEME_SETTINGS = {
11- "org.gnome.desktop.interface" : {
12- "color-scheme" : LIGHT_SCHEME_NAME ,
13- "cursor-theme" : "Fluent-dark-cursors" ,
14- "gtk-theme" : "Fluent-round-Light" ,
15- "icon-theme" : "Fluent-light" ,
16- } ,
17- "org.gnome.shell.extensions.user-theme" : {
18- "name" : "Fluent-round-Light" ,
19- } ,
20- } ;
21-
22- const DARK_THEME_SETTINGS = {
23- "org.gnome.desktop.interface" : {
24- "color-scheme" : DARK_SCHEME_NAME ,
25- "cursor-theme" : "Fluent-dark-cursors" ,
26- "gtk-theme" : "Fluent-round-Dark" ,
27- "icon-theme" : "Fluent-dark" ,
28- } ,
29- "org.gnome.shell.extensions.user-theme" : {
30- "name" : "Fluent-round-Dark" ,
31- } ,
32- } ;
33-
34- function applySettings ( settingsMap ) {
35- for ( let schemaId in settingsMap ) {
36- let schema = new Gio . Settings ( { schema : schemaId } ) ;
37- let keyValues = settingsMap [ schemaId ] ;
38- for ( let key in keyValues ) {
39- schema . set_string ( key , keyValues [ key ] ) ;
40- log ( `LightDarkSwitcher: Setting ${ schemaId } ::${ key } to ${ keyValues [ key ] } ` ) ;
41- }
42- }
43- }
44-
457function hasBattery ( ) {
468 try {
479 let dir = Gio . File . new_for_path ( '/sys/class/power_supply' ) ;
@@ -66,28 +28,9 @@ export default class LightDarkSwitcherExtension extends Extension {
6628 systemIndicator . hide ( ) ;
6729 }
6830 }
69-
70- this . _interfaceSettings = new Gio . Settings ( { schema : 'org.gnome.desktop.interface' } ) ;
71- this . _settingsSignalId = this . _interfaceSettings . connect (
72- 'changed::color-scheme' ,
73- ( ) => this . _syncTheme ( )
74- ) ;
7531 }
7632
7733 disable ( ) {
78- if ( this . _settingsSignalId && this . _interfaceSettings ) {
79- this . _interfaceSettings . disconnect ( this . _settingsSignalId ) ;
80- this . _settingsSignalId = null ;
81- }
82- this . _interfaceSettings = null ;
83- }
8434
85- _syncTheme ( ) {
86- let scheme = this . _interfaceSettings . get_string ( 'color-scheme' ) ;
87- if ( scheme === DARK_SCHEME_NAME ) {
88- applySettings ( DARK_THEME_SETTINGS ) ;
89- } else {
90- applySettings ( LIGHT_THEME_SETTINGS ) ;
91- }
9235 }
9336}
0 commit comments