TC under wine tips with php

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

TC under wine tips with php

Post by *franck8244 »

Hi,
I'm working less and less under windows but I can't give up TC...

As far as TC (under wine) is faster than other linux file manager, I was looking for a way to increase its integration under the linux world (many path problem and opening file)

I think I found a -good- way to do it, you'll just need to have php installed on your linux box.
(I think that it should work with other kind of tool such as perl...)

-P1: Installing php (no advanced options needed)
(a) it depends on your distribution...
* Open a terminal (konsole, xterm, whatever you named it) , see (a)
Maybe php is already intalled, to know it , run "which php"
if there is no result, then php is most likely not installed
otherwise remember the result (something like '/usr/bin/php')
* there is 2 ways to install php,see (a)
1-from a package of your distribution, as root (or with the sudo command), run
** yum install php
or
** apt-get install php
2-from source (downloaded from php.net)
see (a)
** "unzip" the downloaded file
** cd "php_source_dir"
** ./configure
** make
** make install

* re-run "which php" and save the result, I'll call it phpPath

-P2: Creating custom command for TC using php
* save the below the file somewhere on your disk (where it won't move later on), named it "myPhpParser.php"
* get the full linux path to this file (see P1(a))
doing a "sudo updatedb" then a "locate myPhpParser.php" should do just fine
note this full path, I'll call it ParserPath

* find the default path for almost all your linux program (should be /usr/local/bin) I'll call nixPath
* edit tc usercmd.ini with linux tools (tc being closed, I know it's hard ;) )
**create custom command named as you wish
*** cmd=phpPath ParserPath
*** param=WantedLinuxProgram "%P%N"

* reLaunch TC, create new buttons/menu entry calling this user command

-P3 : Launching Program by pressing "enter"
I suggest to use http://www.totalcmd.net/plugring/registry.html
(it's working fine under wine...)

under the HKEY_CLASSES_ROOT section, you'll have to add / edit values to match your need...
for example, I want to open *.c file with the text editor named scite
I modify the [HKEY_CLASSES_ROOT\.c] entry to have
[HKEY_CLASSES_ROOT\.c]
@="txtfile"
[HKEY_CLASSES_ROOT\.c]
"Content Type"="text/plain"

then I have to edit another entry (matching the -@- value)
[HKEY_CLASSES_ROOT\txtfile\shell\open\command]
@="PHPPATH PARSERPATH scite %1"

here it means that when pressing enter on a C file, TC will call
the php file giving it 2 arguments :
1-the program to launch (in this case SCITE)
2- the "WINDOWS" filename to open

Just above we see 2 difference between the M$ world and linux world
In the unix world there is no "\" in a filename...

-Program name : in wine it could be a real mess to launch unix program
-filename : whe have to convert from WINDOWS name to UNIX, we'll do it in the PHP file

read the commented line in the php code below (beginning with a //)


Code: Select all

<?php
$PATH_2_PROGRAM="SET HERE THE VALUE OF nixPath";
$program2Run=$argv[1];
$file2Open=$argv[2];

//In the drive list , we'll tell php what are the WINDOWS drive letters, plus a final "\\" value
//Usually, the WINDOWS simulated C drive is "~/.wine/drive_c/" (~ means current user home directory)

//be sure that the different element of the array match the corresponding -renamed- element
//the last "\\" is to convert the backslash into slash
$driveList=array("C:","D:","\\");
$truePathForDrive=array("~\drive_c\\","PATH_2_THE_D_FOLDER","/");

//Now we launch the linux process ;)
//what php does in the next line is almost concatenation only of the :
//- unix path to "user" program
//- the program the user wanted to launch
//- the WINDOWS filename converted to the unix filename (given specific relation describe in the 2 arrays above)
//- the ' &' meaning : launch it in background (does not always work thought)
exec($PATH_2_PROGRAM.$program2Run.str_replace($driveList,$truePathForDrive,$file2Open)." &");
?>
I have written another php code which allows me to use the %L parameter of TC and launch one program with multiple files,
I'll -upload- it soon.

-P4: Changing icons in TC file list
TC does not know xpm / png format for icons :(
You'll have to find the desired xpm file, convert it to *.ico (IIRC, xpm2ico does the job pretty well), place it
under your "C drive", use the file association dialog to display the desired icons...

EDIT : Similar to the previous program...

Code: Select all

<?php

$prog='/usr/bin/'.$argv[1].' ';

$in_array=array("C:","D:","\\");
$out_array=array("~\drive_c\\","PATH_2_THE_D_FOLDER","/");

$tmpFile=str_replace($in_array,$out_array,$argv[2]);
$fp=fopen($tmpFile,"r");
while (!feof($fp)){
	$cmd="";
	$buffer="";
	$buffer=fgets($fp,1024);
	if (trim($buffer)!=="") exec($prog.str_replace($in_array,$out_array,$buffer.' >/dev/null &'));
	sleep(0.8);
}
fclose($fp);
exit();
?>
TC#88260 -
djorge
Senior Member
Senior Member
Posts: 422
Joined: 2003-07-03, 12:48 UTC
Location: Portugal

Post by *djorge »

Is this method working fine to launch linux programs under total commander under wine?
______________________
David Jorge
Personal License #117854
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

2djorge,
It requires a few work first but it works fine here.
I'm using it everyday @work, there is only linux ...
TC#88260 -
djorge
Senior Member
Senior Member
Posts: 422
Joined: 2003-07-03, 12:48 UTC
Location: Portugal

Post by *djorge »

2franck8244
Currently i'm using krusader at work but i will try your way with the php scripts.

Krusader its not but once we get used to TC it is very hard to use file managers...
______________________
David Jorge
Personal License #117854
seb
Member
Member
Posts: 131
Joined: 2003-03-04, 07:41 UTC

Post by *seb »

a perl solution can now be found here: http://ghisler.ch/board/viewtopic.php?p=134555
pale
Junior Member
Junior Member
Posts: 6
Joined: 2009-03-31, 10:39 UTC

opening multiple files in TC under wine

Post by *pale »

hi "franck8244"!!

i was wondering did you manege to open multiple file with %L parameter..
if you do, please explain how you do it

thx in advance
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

i was wondering did you manege to open multiple file with %L parameter..
if you do, please explain how you do it
When using %L parameter, the script (or program) receives a filename that contains all "windows path" to the -selected files" (one per line)

so the script or program just have to -read- the file and then call each file...
TC#88260 -
pale
Junior Member
Junior Member
Posts: 6
Joined: 2009-03-31, 10:39 UTC

one more question!!

Post by *pale »

hi "franck"

i am curious did you mange to open multiple files through "TC button bar" or with "right click option" or something else

i succeded opening multiple files with button bar adding parameter %S and program luncher path name, it works just fine.

please answer
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

Hi,

Multiple file with "tc button bar" (%L parameter , as described above)
Single File : "tc button bar" (%P%N ) , pressing enter/double click (via a reg entry)

That's all
TC#88260 -
pale
Junior Member
Junior Member
Posts: 6
Joined: 2009-03-31, 10:39 UTC

Post by *pale »

thx for answer franck,

then i was done like you
Post Reply