MegaGlest Forum

MegaGlest => MegaGlest => Topic started by: andy_5995 on 4 January 2016, 01:54:07

Title: cmd arg to change default config directory
Post by: andy_5995 on 4 January 2016, 01:54:07
How can I change the default config directory from the command line when I start megaglest? For testing, I'd like to specify something other than ~/.megaglest

I searched the wiki and forum, and looked at the --help options but didn't see the answer.
Title: Re: cmd arg to change default config directory
Post by: tomreyn on 4 January 2016, 19:25:19
Code: [Select]
$ ./megaglest --help | grep '^--[^ ]*path'
--data-path=x            Sets the game data path to x
--ini-path=x            Sets the game ini path to x
--log-path=x            Sets the game logs path to x
--font-path=x            Sets the game fonts path to x
--show-path-crc=x=y

You probably want to change the ini path, maybe log path, too.
Title: Re: cmd arg to change default config directory
Post by: andy_5995 on 5 January 2016, 22:44:50
Thanks for the reply, Tom, but that data dir is not the same as the userData dir.

Quote
#2 An error occurred and MegaGlest will close.
Error msg = [Regular and User data paths cannot have the same value [../../../../.megaglest-git/]

But perhaps the first question I should have asked: Can I use the same user data dir (~/.megaglest) for 3.11.1 as I do for the development version?

I could hard-code the user data dir into the source code, if I knew which source file to edit. I looked through several yesterday but couldn't find it.

Cheers!
Title: Re: cmd arg to change default config directory
Post by: Omega on 8 January 2016, 05:48:25
Hmm, I wonder why these paths can't be the same. Nothing obvious comes to mind. Given that softcoder implemented this change (https://github.com/MegaGlest/megaglest-source/commit/70421d1b3d78146108cc418dd544e9170d203901), he can probably explain that. These paths probably need to be better explained. The wiki is very tautological.  "--data-path=x sets the game data path to x." Very helpful. I've managed to forget the difference, myself, and can't be bothered doing anything more than a git blame  :P.
Title: Re: cmd arg to change default config directory
Post by: filux on 8 January 2016, 15:54:07
...Can I use the same user data dir (~/.megaglest) for 3.11.1 as I do for the development version?...
Yes but (better) don't try launch different versions at once, with alternate launching there shouldn't be any problems.
Title: Re: cmd arg to change default config directory
Post by: andy_5995 on 8 January 2016, 19:27:22
Thank you, filux
Title: Re: cmd arg to change default config directory
Post by: tomreyn on 8 January 2016, 19:51:44
So here's my take on this:

--ini-path should point to a directory where the game will look for configuration files of the system / global scope. This is glest.ini, glestkeys.ini etc.

glest.ini defines where to look for configuration files of the user / local scope, as configured in UserData_Root.

As such, you can do the following to run one installation with multiple configurations:

Instance 1:
Run megaglest with --ini-path=$HOME/megaglest-1-system
In $HOME/megaglest-ini-1 you store a modified copy of glest.ini, with UserData_Root=$HOME/megaglest-1-user
You also store copies of the other .ini files whose file name do not contain "user" in this directory.
In $HOME/megaglest-1-user you store glestuser.ini - configured to match your needs for this instance.
You (optionally) also store copies of the other .ini files whose file name does contain "user" in this directory.

Instance 2:
Run megaglest with --ini-path=$HOME/megaglest-2-system
In $HOME/megaglest-ini-2 you store a modified copy of glest.ini, with UserData_Root=$HOME/megaglest-2-user
You also store copies of the other .ini files whose file name do not contain "user" in this directory.
In $HOME/megaglest-2-user you store glestuser.ini - configured to match your needs for this instance.
You (optionally) also store copies of the other .ini files whose file name does contain "user" in this directory.

...
Title: Re: cmd arg to change default config directory
Post by: andy_5995 on 9 January 2016, 20:47:18
Thanks for the HOWTO, Tom.

Apparently $HOME couldn't be used after --ini-path because the path following that argument must be a relative path, not an absolute path.

I reference this thread:
ini-path argument using relative path (https://forum.megaglest.org/index.php?topic=9760)
Title: Re: cmd arg to change default config directory
Post by: tomreyn on 12 January 2016, 23:53:57
Hmm right that's not so great. But I guess it can be made to work.

Sorry for suggesting that you could use absolute paths there, I forgot this would not work.
Title: Re: cmd arg to change default config directory
Post by: andy_5995 on 16 January 2016, 20:05:44
Here's a cmd argument that will change the location of $HOME/.megaglest

HOME=/home/andy/.config ./start_megaglest

By temporarily changing the location of HOME, the userDataPath (config dir) will be in /home/andy/.config/.megaglest