LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
8.14k stars 1.01k forks source link

Add a command-line option to use a different resource file #2425

Closed midi-pascal closed 8 years ago

midi-pascal commented 9 years ago

When using various versions of Lmms on the same box you need different lmmsrc.xml files. The goal is to implement a new command-line parameter to specify the resource file to use. The default will stay, well, the default ~.lmmsrc.xml file but the command line -c or --config allow to overwrite it.

Also: 1- In master branch the --help is missing some already existing options: --geometry --import --profile

2- There is a bug in --profile option: it takes profilerOutputFile from argv[1] instead of argv[i]

3- Could it be more clean to display the options in alphabetical order in lmms --help?

I can fix these in the same issue or open separate ones for each.

tresf commented 9 years ago

We may want to take this a step further and in addition to the proposal, do something similar to the data/plugin search paths and default it to a NON-~/.lmmsrc.xml location when being run from the build directory.

midi-pascal commented 9 years ago

@tresf Could you elaborate a bit further on this? In the current implementation I use it like this: lmms --config ~/.lmmsrc-stable.xml for stable version lmms --config ~/.lmmsrc-master.xml for the master branch and so on. If there are some additional requirements I will be pleased to implement them but right now I do not see what you mean.

tresf commented 9 years ago

@midi-pascal this will explain it a bit more:

ConfigManager.cpp#L67

    // If we're in development (lmms is not installed) let's get the source
    // directory by reading the CMake Cache
    QFile cmakeCache(qApp->applicationDirPath() + "/CMakeCache.txt");
    if (cmakeCache.exists()) {
        cmakeCache.open(QFile::ReadOnly);
        QTextStream stream(&cmakeCache);

        // Find the line containing something like lmms_SOURCE_DIR:static=<dir>
        while(! stream.atEnd())
        {
            QString line = stream.readLine();

            if (line.startsWith("lmms_SOURCE_DIR:")) {
                QString srcDir = line.section('=', -1).trimmed();
                QDir::addSearchPath("data", srcDir + "/data/");
                break;
            }
        }

        cmakeCache.close();
    }

The idea is to do something similar for the ~/.lmmsrc.xml path.

midi-pascal commented 9 years ago

@tresf Ok, now I see what you mean. Would the build subdirectory be a good place to put the .lmmsrc.xml?

tresf commented 9 years ago

@midi-pascal I think so although I'd like to hear opinions from other developers too.

zonkmachine commented 8 years ago

:+1: In my ~/ there is a number of .lmmsrc.xml left that has been renamed to save the 'good stuff' from the bad I do while testing would-be awesome ideas. I would love to keep test build trials out of my home directory.

Also: 1- In master branch the --help is missing some already existing options: --geometry --import --profile

2- There is a bug in --profile option: it takes profilerOutputFile from argv[1] instead of argv[i]

3- Could it be more clean to display the options in alphabetical order in lmms --help?

I can fix these in the same issue or open separate ones for each.

@midi-pascal Almost missed these other issues. I'd make an issue for them together or just fix them and make a pull request directly. --geometry it's actually -geometry with only one dash. I wonder if that's an issue too? It looks slightly odd.

midi-pascal commented 8 years ago

@zonkmachine Ok then, working on all these right now :smile:

midi-pascal commented 8 years ago

@zonkmachine The -geometry option is handled by Qt directly so --geometry is not recognized as a valid option. However the second "-" can be removed from argv[] "on the fly" while reading the argument so all options would stay consistent (tested). Kind of a hack but legal: The C99 standard says this about modifying argv (and argc):

<>
zonkmachine commented 8 years ago

However the second "-" can be removed from argv[] "on the fly" while reading the argument so all options would stay consistent (tested).

I think that's a good idea actually. Now it looks a bit like a typo.

midi-pascal commented 8 years ago

@zonkmachine I totally agree with you. A PR for all this issue is almost ready. I am testing all the command-line options to be sure I did not break anything. By the way I also implemented the search for .lmmsrc.xml file in the build directory when in development mode i.e. lmms run from the build directory as @tresf suggested so we can get the best of both: