22import '@girs/gjs' ;
33
44import Gio from "@girs/gio-2.0" ;
5- import { Extension , gettext as _ } from "@girs/gnome-shell/extensions/extension" ;
5+ import { Extension } from "@girs/gnome-shell/extensions/extension" ;
66
7-
8- import { ThemeChanger } from "./modules/themeChanger.ts" ;
9- import { Dock } from "./modules/dock.ts" ;
10- import { NoOverview } from "./modules/noOverview.ts" ;
11- import { PipOnTop } from "./modules/pipOnTop.ts" ;
127import type { Module } from "./modules/module.ts" ;
8+ import { MODULE_REGISTRY , type ModuleDefinition } from "./registry.ts" ;
139
1410/**
1511 * Aurora Shell Extension
16- *
12+ *
1713 * Main extension that orchestrates all modules.
1814 * Each module is independent and can be enabled/disabled separately.
1915 */
@@ -32,26 +28,11 @@ export default class AuroraShellExtension extends Extension {
3228 }
3329
3430 private _initializeModules ( ) : void {
35- if ( this . _settings ?. get_boolean ( 'module-theme-changer' ) ) {
36- this . _modules . set ( 'themeChanger' , new ThemeChanger ( ) ) ;
37- }
38-
39- if ( this . _settings ?. get_boolean ( 'module-dock' ) ) {
40- this . _modules . set ( 'dock' , new Dock ( ) ) ;
41- }
42-
43- if ( this . _settings ?. get_boolean ( 'module-no-overview' ) ) {
44- this . _modules . set ( 'noOverview' , new NoOverview ( ) ) ;
45- }
46-
47- if ( this . _settings ?. get_boolean ( 'module-pip-on-top' ) ) {
48- this . _modules . set ( 'pipOnTop' , new PipOnTop ( ) ) ;
31+ for ( const def of MODULE_REGISTRY ) {
32+ if ( this . _settings ?. get_boolean ( def . settingsKey ) ) {
33+ this . _modules . set ( def . key , def . create ( ) ) ;
34+ }
4935 }
50-
51- // Add more modules here as needed:
52- // if (this._settings?.get_boolean('module-example')) {
53- // this._modules.set('example', new ExampleModule());
54- // }
5536 }
5637
5738 private _enableAllModules ( ) : void {
@@ -67,62 +48,41 @@ export default class AuroraShellExtension extends Extension {
6748 private _connectSettings ( ) : void {
6849 if ( ! this . _settings ) return ;
6950
70- // Watch for theme-changer module setting changes
71- const themeChangerId = this . _settings . connect ( 'changed::module-theme-changer' , ( ) => {
72- this . _toggleModule ( 'themeChanger' , ThemeChanger , this . _settings ! . get_boolean ( 'module-theme-changer' ) ) ;
73- } ) ;
74- this . _settingsHandlers . push ( themeChangerId ) ;
75-
76- // Watch for dock module setting changes
77- const dockId = this . _settings . connect ( 'changed::module-dock' , ( ) => {
78- this . _toggleModule ( 'dock' , Dock , this . _settings ! . get_boolean ( 'module-dock' ) ) ;
79- } ) ;
80- this . _settingsHandlers . push ( dockId ) ;
81-
82- // Watch for no-overview module setting changes
83- const noOverviewId = this . _settings . connect ( 'changed::module-no-overview' , ( ) => {
84- this . _toggleModule ( 'noOverview' , NoOverview , this . _settings ! . get_boolean ( 'module-no-overview' ) ) ;
85- } ) ;
86- this . _settingsHandlers . push ( noOverviewId ) ;
87-
88- // Watch for pip-on-top module setting changes
89- const pipOnTopId = this . _settings . connect ( 'changed::module-pip-on-top' , ( ) => {
90- this . _toggleModule ( 'pipOnTop' , PipOnTop , this . _settings ! . get_boolean ( 'module-pip-on-top' ) ) ;
91- } ) ;
92- this . _settingsHandlers . push ( pipOnTopId ) ;
93-
94- // Add more module watchers here as needed
51+ for ( const def of MODULE_REGISTRY ) {
52+ const handlerId = this . _settings . connect ( `changed::${ def . settingsKey } ` , ( ) => {
53+ this . _toggleModule ( def ) ;
54+ } ) ;
55+ this . _settingsHandlers . push ( handlerId ) ;
56+ }
9557 }
9658
97- private _toggleModule ( name : string , ModuleClass : new ( ) => Module , enabled : boolean ) : void {
98- const existingModule = this . _modules . get ( name ) ;
59+ private _toggleModule ( def : ModuleDefinition ) : void {
60+ const enabled = this . _settings ! . get_boolean ( def . settingsKey ) ;
61+ const existing = this . _modules . get ( def . key ) ;
9962
100- if ( enabled && ! existingModule ) {
101- // Enable module
102- console . log ( `Aurora Shell: Enabling module ${ name } ` ) ;
63+ if ( enabled && ! existing ) {
64+ console . log ( `Aurora Shell: Enabling module ${ def . key } ` ) ;
10365 try {
104- const module = new ModuleClass ( ) ;
66+ const module = def . create ( ) ;
10567 module . enable ( ) ;
106- this . _modules . set ( name , module ) ;
68+ this . _modules . set ( def . key , module ) ;
10769 } catch ( e ) {
108- console . error ( `Aurora Shell: Failed to enable module ${ name } :` , e ) ;
70+ console . error ( `Aurora Shell: Failed to enable module ${ def . key } :` , e ) ;
10971 }
110- } else if ( ! enabled && existingModule ) {
111- // Disable module
112- console . log ( `Aurora Shell: Disabling module ${ name } ` ) ;
72+ } else if ( ! enabled && existing ) {
73+ console . log ( `Aurora Shell: Disabling module ${ def . key } ` ) ;
11374 try {
114- existingModule . disable ( ) ;
115- this . _modules . delete ( name ) ;
75+ existing . disable ( ) ;
76+ this . _modules . delete ( def . key ) ;
11677 } catch ( e ) {
117- console . error ( `Aurora Shell: Failed to disable module ${ name } :` , e ) ;
78+ console . error ( `Aurora Shell: Failed to disable module ${ def . key } :` , e ) ;
11879 }
11980 }
12081 }
12182
12283 override disable ( ) : void {
12384 console . log ( 'Aurora Shell: Disabling extension' ) ;
12485
125- // Disconnect all settings handlers
12686 if ( this . _settings ) {
12787 for ( const handlerId of this . _settingsHandlers ) {
12888 this . _settings . disconnect ( handlerId ) ;
0 commit comments