new environment variable COMMANDER_INSTANCE

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

new environment variable COMMANDER_INSTANCE

Post by *sgp »

I would like a new environment variable COMMANDER_INSTANCE that carries the instance number, the same number that TC prepends, between squared brackets, to the window title. Although the window title of the first instance has no number, COMMANDER_INSTANCE should still be set = 1.
One application I have in mind is reading configuration settings based on TC instance, for instance, in wincmd.ini:

Code: Select all

...
[Buttonbar]
RedirectSection=%COMMANDER_PATH%\config\%COMMANDER_INSTANCE\buttonbar.ini
[Layout]
RedirectSection=%COMMANDER_PATH%\config\%COMMANDER_INSTANCE\layout.ini
[...]
In this example I gain the freedom to easily preset button bar and layout for the first, second, third, and so on window.
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

Not that I oppose the idea but wouldn't it be easier to have several links to TC with different Ini's?
E.g. "/i=My-Special-TC-Config01.ini"
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

ZoSTeR wrote:Not that I oppose the idea but wouldn't it be easier to have several links to TC with different Ini's?
E.g. "/i=My-Special-TC-Config01.ini"
No I don't think so. Besides, mine was just an example of how I would use this new environment variable. And I could use it in several other ways.

It's like COMMANDER_PATH: could we do without it and just create windows shortcut to the installation folder? Sure, but think of many new ideas and possibilities have opened just from having COMMANDER_PATH available.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It is very inconvenient to rely to instance number because you can't control it. E.g. you can't start 10th instance before starting 9 previous.

Custom INI, custom color theme and custom title for different TCs would be more useful.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

MVV wrote:It is very inconvenient to rely to instance number because you can't control it. E.g. you can't start 10th instance before starting 9 previous.
Hi MVV, I agree with everything you said except with the word "inconvenient". Convenience is a subjective matter. I find it convenient to have a sequence id for TC windows. As a matter of fact it is so convenient that the current TC version already adds that number to the title window, and I often look at it. Didn't you ever? All I'm asking for is an environment variable to access that id value.
Custom INI, custom color theme and custom title for different TCs would be more useful.
Maybe but please explain further, what do you have in mind when you write "different TCs"? If by "different" you mean that I need to launch each TC with different command-line options, then it sounds much like the "/i=My-Special-TC-Config01.ini" suggestion, and that isn't what I have in mind for this request thread.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Yes, I mean starting several instances with different command-line options, e.g. from LNKs, and every instance may have its own title (it isn't hard to find some tool that changes title), TC icon (some user already did such thing, it requires a separate icon pack with the only icon for TC window), buttonbar and some other options like background color, you can even define desired environment variable for every instance that may be read from INI (using Autorun plugin), but all other options will remain shared, and it will be possible to do what you want already now.

BTW it is also possible to create a tiny plugin that will read this number from title and set such envvar.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You can try this plugin:

Code: Select all

MIME-Version: 1.0
Content-Type: application/octet-stream; name="CommanderInstance.7z"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="CommanderInstance.7z"

N3q8ryccAAO7ZgM2ZwcAAAAAAAAjAAAAAAAAABxkkvkAJpaOcAAX9+wFu+r0/5QBL0TvfOb1skt4
BMvR6HvW2Z7CPl77UePEVJRIrv0lIlfV7jrTmoQioL68N+nm796CU+jvz+whNNABTrYB5/PK7gxZ
wj87TETZ9KRdBTh/gZB4KDFeh0GBtAN3FE8IgiUwA4HGP6UUhSWIPrW7pF91s+OP5uSvDvJvxRbH
8YXBbpYjE3D6bb1jsKtH6VOhnvTp1NYiB78ZgkI0fO/TlycL6uVLt37xMfJDq0gYWJY0i1B5j38U
d0TuFqXiUD1kJyi++u8s41Rl5FCEGB0EYxYl0qPT3xdsaKqouL0EItlCcL7jAZXTE2BQUNDe4v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zXGwD4ajKcD1s2vS
+Crr+oYkkPSaYXx0Gma5+O6x182Yb609l0PxjqBZXX/MHXtKkIqT0csd1Bf3ABcGhtgBCYCPAAcL
AQABIwMBAQVdABAAAAyA5woBlEW+iwAA
When loaded, it will add desired environment variable. It should be installed like Autorun or TCFS2Tools plugins. First way is to register CommanderInstance.dll as WDX plugin and to define special 'color by file type' preset (Configuration, Color, by file type, Add, Define, Plugins tab, "CommanderInstance.Autorun > 0", save with any name, apply all changes) to cause TC to load CommanderInstance automatically. Second way is to start it via Autorun plugin if you have it.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

MVV, thanks! Lots of good ideas in your post (the one to the last), and your dll works fine here (XP 32bit, loaded with Autorun). I can begin experimenting with COMMANDER_INSTANCE now. Thank you again.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

I discovered one flaw in using CommanderInstance.dll inside wincmd.ini, possibly due to my loading the dll via the Autorun.wdx plugin.
To illustrate the flaw, I added this redirection to wincmd.ini

Code: Select all

[lefttabs]
RedirectSection=left[%COMMANDER_INSTANCE%].ini
The idea is for each instance to have its own left tab ribbon by automatically saving each [lefttabs] section in its own file named "left[1].ini", "left[2].ini" and so on.
In early testing this seemed to work with one minor caveat: file left[N].ini must exist before instance N starts.

If the file doesn't exist then TC picks "left[1].ini" even when, i.e., COMMANDER_INSTANCE = 3. I tested this by executing menu entry Configuration>Save Settings from TC instance #3: TC saved the left tabs into "left[1].ini" instead of "left[3].ini". Curiously, if you don't execute Configuration>Save Settings but simply exit instance #3, the right file name is created as "left[3].ini' BUT it's empty (no tabs saved). At this point you can restart instance 3, which will then behave correctly, by saving the tabs to "left[3].ini", since instance 3 found file "left[3].ini" existing when it started.

I have no evidence of the following, but I suspect that when TC calls CommanderInstance.dll the dll can only report 1 as the instance number, perhaps because it isn't yet fully loaded. Then after TC has displayed the instance UI the dll can return the real instance number.

edit: after some more testing I see that regardless of the instance number, each instance reads its initial state from "left[1].ini", if it exists. Of course this makes saving exit state into "left[N].ini" pointless.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

There may be a problem if TC uses variable too early. When plugin is loaded, TC title doesn't contain number yet (it is simply "Total Commander"), so I have to create separate thread and wait, and set variable to accurate number a bit later.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

MVV wrote:There may be a problem if TC uses variable too early. When plugin is loaded, TC title doesn't contain number yet (it is simply "Total Commander"), so I have to create separate thread and wait, and set variable to accurate number a bit later.
Do you think it will fix the application problem? I wonder. If TC reads wincmd.ini before it loads the UI - as it seems reasonable to me - the title bar shouldn't exist when TC resolves section [lefttabs] hence variable %COMMANDER_INSTANCE% will always be 1.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It doesn't fix the problem but I get instance number as fast as I can, unfortunately of course it becomes available only after some time from application start. Autorun plugin is also loaded only when window exists and needs to draw its contents.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

Thank you. So for my application and for broadest usage COMMANDER_INSTANCE should be implemented directly in TC, a plugin can't be enough. Do you agree?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Perhaps another kind of auto-loading plugins would be more useful, and instance number could be calculated in the way TC does it w/o waiting for it in the title.
User avatar
nsp
Power Member
Power Member
Posts: 1950
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: new environment variable COMMANDER_INSTANCE

Post by *nsp »

sgp wrote:I would like a new environment variable COMMANDER_INSTANCE that carries the instance number, the same number that TC prepends, between squared brackets, to the window title. Although the window title of the first instance has no number, COMMANDER_INSTANCE should still be set = 1.
One application I have in mind is reading configuration settings based on TC instance, for instance, in wincmd.ini:
...
What you can do is a small TC Launcher/Wrapper that sets the TC instance variable before launching TC and reuse it.
If you want get info at load time before plugin list is even loaded. It as either to be implemented inside TC (as you ask) or externally using your own wrapper.
Post Reply