Read the statement by Michael Teeuw here.
Remove module configuration from config/config.js
-
Hi,
I am not sure if this would impact the core system of the Magic Mirror. The feature/change is like this:
The module configuration that is currently being added to the config/config.js could be moved to a file called “module.js” (or some other name) inside the module’s folder, a name that would be static so the core system knows what to look for. When the MagicMirror bootstraps, it would run through all the folders inside the modules subfolder and would load this “module.js” config file and also the other files for the module. This way the custom module would become just a drop-in module with no changes required to the MagicMirror.
The system would detect any modules inside the modules subfolder and would load them, without having to change the config.js.
Is this something that could be done without too much impact in the core of the application? I haven’t looked at JS for a while (java backend developer here), but I can take a look at the source code and come up with a strategy for dynamically loading modules.
Thank you
(this could be an alternate solutions for: https://forum.magicmirror.builders/topic/17/use-npm-for-module-installs). Less configuration changes in the core system just to install a module.
-
While that would be cool, you would still have to config the size, location, customize, etc. right? I mean adding a module to the config file is not really too difficult.
-
@hartattack said in Remove module configuration from config/config.js:
customize
No, all the module customization and configuration would live inside this static module.js file inside the module’s folder. Whatever is put int the config/config.js regarding a module, it would be moved to this file inside the module’s folder.
The code system could validate for the mandatory fields of the configuration entries like module, location and any other that is required by the core of the MM.
-
@thiagolocatelli Well, all you would do is disperse a lot of settings/options in to each module instead of having the settings centralized in one file as it is now.
however, a “scraper” script would be good for the newbies, i.e a script that scans the modules folder, adds each module and retrieves all config-defaults from each module and puts it all in a new config file.
This way you will get all the settings that can be changed within the module (since every module has it’s own) readily displayed in the right format just for the user to alter.
-
@broberg said in Remove module configuration from config/config.js:
however, a “scraper” script would be good for the newbies, i.e a script that scans the modules folder, adds each module and retrieves all config-defaults from each module and puts it all in a new config file.
Thats also an interesting approach and the core system could also monitor the modules folder, so whenever a new module is copied to that folder, the core system would reload the modules or just load the new module and refresh the UI. The same could apply to removing a module, without having to restart the system, if the core detects a folder is not there, it can refresh the UI and remove the module.