MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

Create another config.js file



  • Hi, so for a project that I’m working on, I want to create multiple config.js files and name them like config1.js, config2.js and etc. But in order to open on of them (so like the config2.js for example) while booting the MagicMirror, I need to change the path or the configuration that defaults it to config.js. Does anyone know how I can do that?



  • @BigMan I would create different scripts, and copy your specific config.js into the config folder as config.js.



  • @sdetweil can you please elaborate more on your response. If you can, with examples too. Thanks!



  • @BigMan create a folder called ~/MagicMirror/myConfigs
    place you config1, config2 … confign…js in there

    MM starts with a script installers/mm.sh (or u can create your own)

    anyhow…

    lets create run1.sh in installers

    #!/bin/bash
    # copy my config.js into the folder with the required name
    cp ~/MagicMirror/myConfigs/config1.js ~/MagicMirror/config/config.js
    # then call mm.sh
    exec ~/MagicMirror/installers/mm.sh
    

    then after saving, do

    chmod +x run1.sh
    

    then whenever u want to run MM with config1

    just do

    ~/MagicMirror/installers/run1.sh
    

    u can shorten the commands if u are in the MagicMirror folder at the time…

    create as many run?.sh as u need

    I might save the original config.js in your folder too


  • Project Sponsor Module Developer

    @BigMan Since version 2.1.1 this is natively supported by MagicMirror²

    Enable ability to set configuration file by the environment variable called MM_CONFIG_FILE.

    To test it you can run MM_CONFIG_FILE=YOUR_PATH_TO_CONFIG_FILE npm start in the terminal.



  • @BigMan said in Create another config.js file:

    even easier!
    put all your configs into the config folder
    then just set which on to use

     #!/bin/bash
     # set my config 
     export MM_CONFIG_FILE=~/MagicMirror/config/config1.js
     # then call mm.sh
     exec ~/MagicMirror/installers/mm.sh
    

    thanks @strawberry-3-141


Log in to reply