Total Commander under Wine: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
(Alternative approach to register file assocations from https://community.linuxmint.com/tutorial/view/222)
(→‎Some tips setting things up: Improved readability of the page source by adding line breaks in comments)
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== How to have a lot of fun with your favourite tool in linux / under wine?! ==
This page gives tips for using '''Total Commander under Wine''' on Linux systems.


# '''have the systems keyboard shortcuts disabled'''<br>in ubuntu v7.0.4, i had to disable for example ALT+F1, ALT+F2, ALT+F5 and ALT+F6<br>those are essential to my life with total commander<br>the last one was a bit tricky, cause its not to be switched off in the easy to reach tools of gnome<br>i had to start gconf-editor via shell and search for '<Alt>F6' to get rid of that :-)<br>
== Some tips setting things up ==
# '''have a decent wine version installed'''<br>i just tested tc v7.0.1 under wine v0.9.45<br>i haven't found any serious flaws<br>
 
# '''have msttcorefonts installed'''<br>you will have much more fun on comparing two files by content if you have this package installed, trust me! ;)<br>on a debian based system try: ''sudo apt-get install msttcorefonts''<br>
# '''Disable colliding system keyboard shortcuts!'''<br /><!--
# '''have filetypes associated and a fitting wrapper installed'''<br>integration of total commander in the linux system will be much better, if you can start all those files right away<br>
--> In Ubuntu v7.0.4, the shortcuts ALT+F1, ALT+F2, ALT+F5 and ALT+F6 can be switched off via gconf-editor in a shell and searching, for example, for '<Alt>F6'
## there is a nice PERL tool for this purpose: [http://www.ghisler.ch/board/viewtopic.php?p=134602 wine_wrapper]<br>this will adjust the file associations, so you can start files out of your wine with the according native linux apps<br>( you might also want to have a look at [http://www.ghisler.ch/board/viewtopic.php?t=16226 this] for a different tool in php )
# '''Install msttcorefonts for better readability!'''<br /><!--
## there is also another way to get the same behavior (IMHO a better way): [http://community.linuxmint.com/tutorial/view/222 http://community.linuxmint.com/tutorial/view/222]
--> On a Debian based system, try: ''sudo apt-get install msttcorefonts''


== Further tips & tricks ==
== Further tips & tricks ==
Line 28: Line 28:
In Total Commander
In Total Commander


1. in the Menu item Files -> Internal Associations
# In the Menu item Files -> Internal Associations
2. Click Add, then in File Type line enter *.*, click OK, and
# Click Add, then in File Type line enter *.*, click OK, and
3. in Actions Open box enter  
# In Actions Open box enter<!--
 
--><pre>c:\windows\system32\winebrowser.exe "%1"</pre>
c:\windows\system32\winebrowser.exe "%1"
# Finally Click OK and OK.
 
4.  Finally Click OK and OK.
 
Alternatively, to register only those file associations already registered in Linux:
 
1. Open Wine Regedit by:
 
wine regedit
 
2. Navigate to HKEY_CURRENT_USER (a.k.a HKCU) -> Software -> Wine and look for a key called "WineBrowser". If it does not exist, create it. Under the newly created "WineBrowser" key, create a string called "Browsers" with the following value:
 
xdg-open,firefox
 
3. Save the file https://github.com/MestreLion/wine-tools/blob/master/wine-import-extensions  as wine-import-extensions, and make it executable by


chmod +x wine-import-extensions
Alternatively, to register all file associations already registered in Linux for all applications (not only Total Commander) of the bottle :


4. Run it on the bottle containing the installation of Total Tommander, say named TotalCmd, by
# Open Wine Regedit by:<!--
--><pre>wine regedit</pre><!--
wine-import-extensions --bottle TotalCmd
-->
# Navigate to HKEY_CURRENT_USER (a.k.a HKCU) -> Software -> Wine and look for a key called "WineBrowser". If it does not exist, create it. Under the newly created "WineBrowser" key, create a string called "Browsers" with the following value:<!--
--><pre>xdg-open,firefox</pre><!--
-->
# Save the file https://github.com/MestreLion/wine-tools/blob/master/wine-import-extensions  as wine-import-extensions, and make it executable by<!--
--><pre>chmod +x wine-import-extensions</pre><!--
-->
# Run it on the bottle containing the installation of Total Tommander, say named TotalCmd, by<!--
--><pre>wine-import-extensions --bottle TotalCmd</pre><!--
-->


Observations:  
Observations:  
Line 58: Line 53:
* If the folder containing the executable wine is not in $PATH, then
* If the folder containing the executable wine is not in $PATH, then


1. wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine,
:# wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine,
2. the folder containing it has to be added to $PATH before calling wine-import-extensions
:# the folder containing it has to be added to $PATH before calling wine-import-extensions


* If $WINEBOTTLEHOME or $WINEPREFIX differ from its standard values $HOME/.wine respectively $XDG_DATA_HOME/wineprefixes, then they have to be passed to wine-import-extensions. For example, in the case of Crossover, the complete command reads
* If $WINEBOTTLEHOME or $WINEPREFIX differ from its standard values $HOME/.wine respectively $XDG_DATA_HOME/wineprefixes, then they have to be passed to wine-import-extensions. For example, in the case of Crossover, the complete command reads<!--
 
--><pre>env PATH=$PATH:/opt/cxoffice/bin WINEBOTTLEHOME=$HOME/.cxoffice WINEPREFIX=$HOME/.cxoffice wine-import-extensions --bottle TotalCmd</pre>
env PATH=$PATH:/opt/cxoffice/bin WINEBOTTLEHOME=$HOME/.cxoffice WINEPREFIX=$HOME/.cxoffice wine-import-extensions --bottle TotalCmd


=== Use Total Commander as Default File Manager ===
=== Use Total Commander as Default File Manager ===
Line 69: Line 63:
To open directories in Total Commander as default file manager:
To open directories in Total Commander as default file manager:


Add to  
Add to <code>~/.config/applications/mimeapps.list</code> or <code>~/.config/mimeapps.list</code> in Sections <code>[Added Associations]</code> and <code>[Default Applications]</code> the line:
 
~/.config/applications/mimeapps.list
 
or ~/.config/mimeapps.list in Section [Added Associations] the line


  inode/directory=file-manager.desktop
  inode/directory=file-manager.desktop


and create the file  
and create the file <code>~/.config/applications/file-manager.desktop</code> with content:
 
~/.config/applications/file-manager.desktop
 
with content


  [Desktop Entry]
  [Desktop Entry]
  Type=Application
  Type=Application
  Name=Total Commander
  Name=Total Commander
  Exec=totalcmd /O /T "%s"
  Exec=totalcmd /O /T %u


and a file totalcmd in $PATH starting Total Commander in, say with content
and create a file <code>totalcmd</code> in $PATH starting Total Commander in, say with content:


  #!/bin/sh
  #!/bin/sh
Line 105: Line 91:
  [em_CopyFullNamesToClip]
  [em_CopyFullNamesToClip]
  cmd=/bin/sh
  cmd=/bin/sh
  param=-c "echo ""$(realpath ""$(wine --bottle TotalCmd winepath --unix ""%P%S1"")"")"" | xclip -in -selection c"
  param=-c "cat ""$(wine --bottle TotalCmd winepath --unix ""%UL"")"" | sed -e '1s/^\xEF\xBB\xBF//' | xargs --delimiter='\n' wine --bottle TotalCmd winepath --unix | sed -e 's/\r$//' | xclip -in -selection clipboard"
 
and to wincmd.ini in the section [Shortcuts] the line
 
CS+C=em_CopyFullNamesToClip
 
to copy the full Linux path of the currently selected files to the clipboard by Control+Shift+C
 
Observations:
 
* to remove the trailing line feed, add head -c -1 | before xclip
* xclip has to be in $PATH (which it is on many Linux distributions; otherwise xsel is an alternative)
* If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
* The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.
 
=== Shortcut to Create Symlink ===
 
Add to usercmd.ini the lines
 
[em_UNIXlink]
button=,-1
cmd=/bin/sh
param=-c "ln -s ""$(realpath ""%S"")"" -t ""$(wine --bottle TotalCmd winepath --unix ""%t"")"""
 
and to wincmd.ini in the section [Shortcuts] the line
 
C+F7=em_UNIXlink
 
to let <code>Ctrl+F7</code> create a symlink of the selected file/directory in the target tab directory.
 
Observations:
 
* If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
* The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.
 
=== Shortcuts as Ersatz for Ctrl+C/X/V ===
 
Total Commander in Wine does not allow for copying and moving files by <code>Ctrl+C/X/V</code>.
Instead, add to wincmd.ini in the section [Shortcuts] the lines
 
C+C=cm_CopySamepanel
C+X=cm_RenMov
C+V=cm_EditNewFile
 
to map them to Total Commander built-in functions resembling those in Microsoft Windows.
 
=== Open Krusader in Current Work Dir ===
 
Since Krusader has better support for Drag and Drop, sometimes dragging files from Krusader, instead of Total Command, is called for:
 
Add to usercmd.ini the lines
 
[em_ExecuteKrusader]
cmd=/bin/sh
param=-c "krusader --left ""$(wine --bottle TotalCmd winepath --unix '%X%p')"" --right ""$(wine --bottle TotalCmd winepath --unix '%X%t')"""


and to wincmd.ini the line  
and to wincmd.ini the line  


  CS+C=em_CopyFullNamesToClip
  F12=em_ExecuteKrusader


to copy the full Linux path of the currently selected file to the clipboard by Control+Shift+C
to open the currently open directory in Krusader by hitting F12.


Observations:  
Observations:


* If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
* If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
* The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.
* The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.
* xclip has to be in $PATH (which it is on many Linux distributions)


=== Call native applications from Button bar ===
=== Call native applications from Button bar ===

Latest revision as of 10:22, 28 December 2023

This page gives tips for using Total Commander under Wine on Linux systems.

Some tips setting things up

  1. Disable colliding system keyboard shortcuts!
    In Ubuntu v7.0.4, the shortcuts ALT+F1, ALT+F2, ALT+F5 and ALT+F6 can be switched off via gconf-editor in a shell and searching, for example, for '<Alt>F6'
  2. Install msttcorefonts for better readability!
    On a Debian based system, try: sudo apt-get install msttcorefonts

Further tips & tricks

Edit file in native editor

To edit the file in a native editor, say Gvim, on hitting F4, set the Editor to the following command in Settings/Operations/Viewer/Editor:

/bin/sh -c "gvim ""$(realpath ""$(wine --bottle TotalCmd winepath --unix ""%1"")"")"""

Observations:

  • If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
  • The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.
  • Replace gvim to the command name of your favorite editor

Open file in native application

To open the file in the native application associated to it in Total Commander, try first the following:

In Total Commander

  1. In the Menu item Files -> Internal Associations
  2. Click Add, then in File Type line enter *.*, click OK, and
  3. In Actions Open box enter
    c:\windows\system32\winebrowser.exe "%1"
  4. Finally Click OK and OK.

Alternatively, to register all file associations already registered in Linux for all applications (not only Total Commander) of the bottle :

  1. Open Wine Regedit by:
    wine regedit
  2. Navigate to HKEY_CURRENT_USER (a.k.a HKCU) -> Software -> Wine and look for a key called "WineBrowser". If it does not exist, create it. Under the newly created "WineBrowser" key, create a string called "Browsers" with the following value:
    xdg-open,firefox
  3. Save the file https://github.com/MestreLion/wine-tools/blob/master/wine-import-extensions as wine-import-extensions, and make it executable by
    chmod +x wine-import-extensions
  4. Run it on the bottle containing the installation of Total Tommander, say named TotalCmd, by
    wine-import-extensions --bottle TotalCmd

Observations:

  • If the folder containing the executable wine is not in $PATH, then
  1. wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine,
  2. the folder containing it has to be added to $PATH before calling wine-import-extensions
  • If $WINEBOTTLEHOME or $WINEPREFIX differ from its standard values $HOME/.wine respectively $XDG_DATA_HOME/wineprefixes, then they have to be passed to wine-import-extensions. For example, in the case of Crossover, the complete command reads
    env PATH=$PATH:/opt/cxoffice/bin WINEBOTTLEHOME=$HOME/.cxoffice WINEPREFIX=$HOME/.cxoffice wine-import-extensions --bottle TotalCmd

Use Total Commander as Default File Manager

To open directories in Total Commander as default file manager:

Add to ~/.config/applications/mimeapps.list or ~/.config/mimeapps.list in Sections [Added Associations] and [Default Applications] the line:

inode/directory=file-manager.desktop

and create the file ~/.config/applications/file-manager.desktop with content:

[Desktop Entry]
Type=Application
Name=Total Commander
Exec=totalcmd /O /T %u

and create a file totalcmd in $PATH starting Total Commander in, say with content:

#!/bin/sh
exec "wine" --bottle "TotalCmd" --check --wait-children --start "C:/users/crossover/Start Menu/Programs/Total Commander/Total Commander.lnk" "$@"

Observations:

  • If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
  • The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.
  • This assumes that Total Commander was installed adding Links to the Start Menu; otherwise the path of its executable instead of that to its link has to be given, say C:\TotalCmd\totalcmd.exe

Shortcut to Copy Linux Filepaths to Clipboard

Add to usercmd.ini the lines

[em_CopyFullNamesToClip]
cmd=/bin/sh
param=-c "cat ""$(wine --bottle TotalCmd winepath --unix ""%UL"")"" | sed -e '1s/^\xEF\xBB\xBF//' | xargs --delimiter='\n' wine --bottle TotalCmd winepath --unix | sed -e 's/\r$//' | xclip -in -selection clipboard"

and to wincmd.ini in the section [Shortcuts] the line

CS+C=em_CopyFullNamesToClip

to copy the full Linux path of the currently selected files to the clipboard by Control+Shift+C

Observations:

  • to remove the trailing line feed, add head -c -1 | before xclip
  • xclip has to be in $PATH (which it is on many Linux distributions; otherwise xsel is an alternative)
  • If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
  • The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.

Shortcut to Create Symlink

Add to usercmd.ini the lines

[em_UNIXlink]
button=,-1
cmd=/bin/sh
param=-c "ln -s ""$(realpath ""%S"")"" -t ""$(wine --bottle TotalCmd winepath --unix ""%t"")"""

and to wincmd.ini in the section [Shortcuts] the line

C+F7=em_UNIXlink

to let Ctrl+F7 create a symlink of the selected file/directory in the target tab directory.

Observations:

  • If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
  • The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.

Shortcuts as Ersatz for Ctrl+C/X/V

Total Commander in Wine does not allow for copying and moving files by Ctrl+C/X/V. Instead, add to wincmd.ini in the section [Shortcuts] the lines

C+C=cm_CopySamepanel
C+X=cm_RenMov
C+V=cm_EditNewFile

to map them to Total Commander built-in functions resembling those in Microsoft Windows.

Open Krusader in Current Work Dir

Since Krusader has better support for Drag and Drop, sometimes dragging files from Krusader, instead of Total Command, is called for:

Add to usercmd.ini the lines

[em_ExecuteKrusader]
cmd=/bin/sh
param=-c "krusader --left ""$(wine --bottle TotalCmd winepath --unix '%X%p')"" --right ""$(wine --bottle TotalCmd winepath --unix '%X%t')"""

and to wincmd.ini the line

F12=em_ExecuteKrusader

to open the currently open directory in Krusader by hitting F12.

Observations:

  • If the folder containing the executable wine is not in $PATH, then wine has to be replaced by its full path; in case of Crossover it is /opt/cxoffice/bin/wine.
  • The name of the bottle, here TotalCmd, can be omitted if a default bottle is set.

Call native applications from Button bar

You can easily call native applications for a selected file by using either the script that is linked here http://community.linuxmint.com/tutorial/view/222 or by using the following script:

#!/bin/sh
$1 `wine winepath -u "$2"` $3 $4;

Save the file as linuxcaller.sh, and make it executable by typing chmod +x linuxcaller.sh

Now you can create buttons generically by using the script as command. As parameters you can pass the actual native linux command that you want to execute and the %P%N parameters and maybe some more in case you need it.

You can copy and paste this predefined button, you must adjust the paths. This example calls Pinta (Image viewer) with the selected file.

TOTALCMD#BAR#DATA
Z:\home\sebastian\scripts\nixcaller3.sh
pinta %P%N
%COMMANDER_PATH%\WCMICONS.DLL,26
Open with Pinta
%P

-1


(Works for me under Mint 17.1 and XFCE)

Copy Filepaths to Clipboard

Here is a small script that enables you to copy a valid Linux path of selected file(s) in Total Commander

(Works under Mint 17.1 with XFCE with one or multiple selected files)

#!/bin/sh
outputp=""
for var in "$@" do currentpath=`wine winepath -u "$var"`; outputp=$outputp$currentpath'\n'; done echo $outputp | xclip -selection clipboard;

To use this script

  • save the script in a file named e.g. clip.sh and put it into e.g. /home/user/scripts
  • make script executable, i.e. chmod +x clip.sh
  • create Button in TC and use

command: Path to script parameter: %P%N

  • Important: make sure you have xclip installed. It might not be included in your distro. Usually "sudo apt-get install xclip" should do it.

or copy the text below and paste it onto TC Button bar and then adjust paths.


TOTALCMD#BAR#DATA
Z:\home\sebastian\scripts\clip.sh
%P%S
%COMMANDER_PATH%\WCMICONS.DLL,59
Copy Fullname As LinuxPath


-1


Troubleshooting

While porting the scripts from one computer to another i found it helpful to simply run the scripts from a terminal and see whether they are working or throw an error message which you will not see when calling them via TC buttonbar!

Furthermore:

  • make sure scripts are executable: chmod +x filename.sh
  • make sure path is correct
  • make sure tools are installed (like xclip)


Make more use of the Drive-Bar

By default Wine only configures the C: drive for the "simulated" Windows System drive and the Z: drive for the actual root file system. This makes the Total Commander Drive bar quite empty.

To add more "virtual drives" to the drive bar you can simply create symbolic links to anywhere.

To create a new Drive that is actually your home folder, open a terminal and type:

cd ~/.wine/dosdevices
ln -s /home/sebastian/ s:

Which will create a drive with letter S in wine that is your homepath.