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 /
pdf
Enter
comment out the following lines (just for a backup):
# PDF
#type/^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
type/^PDF
Open=~/MyApps/start-pdf-mc.sh
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:
#!/bin/bash
Filename="z:"${MC_EXT_FILENAME//\//\\}
App=`eval wine "~/MyApps/PDF-XChange_Viewer/PDFXCview.exe" "'$Filename'" > /dev/null 2>&1 &`
$App
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
AND
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)
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:
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