Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
midi-pascal opened this issue Oct 22, 2015 · 10 comments
Closed

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

midi-pascal opened this issue Oct 22, 2015 · 10 comments

Comments

@midi-pascal
Copy link
Contributor

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
Copy link
Member

tresf commented Oct 22, 2015

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
Copy link
Contributor Author

@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
Copy link
Member

tresf commented Oct 22, 2015

@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
Copy link
Contributor Author

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

@tresf
Copy link
Member

tresf commented Oct 22, 2015

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

@zonkmachine
Copy link
Member

👍
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
Copy link
Contributor Author

@zonkmachine Ok then, working on all these right now 😄

@midi-pascal
Copy link
Contributor Author

@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):
<<The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program, and retain their last-stored values between program startup and program termination.>>

@zonkmachine
Copy link
Member

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
Copy link
Contributor Author

@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:

  • in dev mode, .lmmsrc.xml is searched in the build directory by default
  • this can be overridden by specifying --config at the command-line either in dev mode or with lmms fully installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants