I want to use PDF-XChange Editor to open pdf files from within mc. I tryed setting

Open=wine ~/PDFXEdit6_Portable/PDFXEdit.exe %f

in mc.ext, but it opens only the application, not the file.


It seems to me the syntax of this field is close to that of exec in .desktop files, so I tried to adapt some of the solutions proposed on How to pass file as argument in .desktop file for wine application, but without success yet.

2 Answers 2


For me, the solution was to add z: near the end of the command line:

Open=wine ~/PDFXEdit6_Portable/PDFXEdit.exe z:%f

I tested with PDF X-Change Editor, in the shortcut, and it worked too:

env WINEPREFIX="/home/jim/.wine" wine-stable C:\\windows\\command\\start.exe /Unix /home/jim/.wine/dosdevices/c:/users/jim/Start\ Menu/Programs/Tracker\ Software/PDF-XChange\ Editor.lnk z:%f


Short answer.

You are using %f, but the filename you want to pass is stored in ${MC_EXT_FILENAME} variable.

Long answer.

How to open / view PDF files using Midnight Commander + Wine + PDF-XChange Viewer / Editor Portable

Note: I assume that Windows portable apps are stored in "~/MyApps/*"

  • open Midnight Commander extension file for editing: F9 -> Command -> Edit extension file
  • navigate to the section of the file where PDF configuration is written: type /pdfEnter
  • comment out the following lines (just for a backup):

    # PDF
    #       Open=/usr/lib/mc/ext.d/doc.sh open pdf
    #       View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view pdf

  • add / replace with the following lines:

    # PDF
        View=%view{ascii} ~/MyApps/start-pdf-mc.sh

  • save the changes and exit: :wqEnter

  • create the ~/MyApps/start-pdf-mc.sh file with the following content:

    App=`eval wine "~/MyApps/PDF-XChange_Viewer/PDFXCview.exe" "'$Filename'" > /dev/null 2>&1 &`

Note: You might want to create it in /usr/lib/mc/ext.d/*.sh (instead of ~/MyApps/ as I did).

  • make sure start-pdf-mc.sh file is executable (use chmod).

Explanation of the start-pdf-mc.sh file

  • the filename we are trying to open is stored in ${MC_EXT_FILENAME} variable

  • when using wine, use drive letter z:

  • convert Linux-style file path (/) to Windows-style (\) with the following: ${MC_EXT_FILENAME//\//\\} to pass it as an argument to PDF-XChange Viewer later

  • > /dev/null 2>&1 and & are required to discard program output and to run it as a background process, otherwise (if you omit this), you won't be able to use Midnight Commander till you close PDF-XChange Viewer, which is obviously not desirable.

Tested with the following software

  • Linux Debian 32-bit

  • GNU Midnight Commander 4.8.13

  • wine-1.6.2

  • PDF-XChange Viewer v2.5.316.1


  • Linux Debian 32-bit

  • GNU Midnight Commander 4.8.13

  • wine-1.6.2

  • PDF-XChange Editor v6.0.321.0

Update according to your comment

It seems that there is still some error in the filepath... Let's try to correct it.

    • Open the problematic PDF file with PDFXChange Editor (as you usually do, NOT with the Midnight Commander)

    • File -> Copy Full File Name

    • Paste it into any text file (just for later reference)

    • Close PDFXChange Editor

    • Open the same file with Midnight Commander + PDFXChange Editor (which shows your error message)

    • Compare if the file paths are identical (the one that you've just pasted for reference and the one in your error message)

    • If the paths are NOT identical – correct the path accordingly in .sh file OR paste them here for me to help (just replace your username in the path with <username> for security)

  1. Also, this is not so likely, BUT if the paths ARE identical there might be an issue with permissions that are set on the file you are trying to open. Thus verify your file permissions are at least:

    sudo chmod 644 your-file-name-here.pdf

Update 2

It is possible to have access to all files from all drives including those that are NOT located in the ~/* (home user directory) or even stored on other HDDs just by using Z:\ (not using H:\ and other drive letters at all).

Check your drive mapping in Wine:

  • run in terminal

    $ winecfg
  • open the Drives tab

  • the following records have to be there by default

    Letter | Drive Mapping
    C:     | ../drive_c
    Z:     | /

As far as I know, any path starts with / (for any file on any HDD accessed in Linux) and thus can be accessed using the Z:\, because of the mapping described above.

For example, the above config allows me to access a PDF file

  • from /home/<username>/*.pdf (~/*.pdf), if it's located in home user directory
  • from /media/<drive-label>/*.pdf OR /mnt/<drive-label>/*.pdf, if it's located on some external drive or HDD, that I've mounted; (in Windows the same drive might be accessed using the H:\, for example)

Drive mappings, however, would be another question, specific to your setup. :-)

BTW, one more thing to check. Is your user home directory ~/* mapped to wine's My Documents folder?

  • in terminal: $ wine explorer
  • double click on My Documents folder
  • you should see the contents of your Linux ~/* home directory
  • Thanks for helping. I get an error, though: PDFXChange Editor says An error occurred while opening the document from the file: z:\home\...\file.pdf Error [operating system]: path not found. Apr 22, 2017 at 9:29
  • Answer updated. Please, check it and report the results. Apr 22, 2017 at 15:35
  • I think the problem is that the ${MC_EXT_FILENAME} is an absolute path while the "full file name" is relative to my home. The full file name is H:\Downloads\file.pdf, the Downloads folder is in /home/me/Downloads. Apr 23, 2017 at 8:31
  • How have you managed to get to the H:\ drive letter from MC? Anyway, check out update 2. Apr 23, 2017 at 18:48
  • My Documents is not mapped to ~/ and I don't want it so. Anyway, I didn't have Z: mapped to /. I added it and now it works. Thank you :-) Apr 23, 2017 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.