How to enable a Windows application in WINE to access a Samba share on a NAS (continued)

In a 2016 post ‘How to enable a Windows application in WINE to access a Samba share on a NAS‘ I explained how to mount in Linux a networked SMB shared folder so that a Windows application running via WINE could access the folder as Drive Y: in order to open and save files in it. In that blog post I also listed a couple of Bash scripts to facilitate the mounting and unmounting of the SMB share for the WINEPREFIX used for the Windows application (~/.wine-pdfxve6 in the example I gave for PDF-XChange Editor, Version 6). However, as I have several Windows applications running via WINE on my machines, and I have used a different WINEPREFIX for each of them, I wanted to be able to mount the SMB share for whichever of those applications I happen to be using at the time. Therefore I modified the original Bash scripts as shown below. The Desktop Configuration files (.desktop files) to launch the scripts are essentially the same as in my earlier blog post; I have just removed the references to the specific Windows application. The four modified files are listed below. Obviously change the username, SMB share name and SMB server name to suit your own situation.

1. Bash script ~/mount_bsfnas1_brianfolder_share.sh

#!/bin/bash
mount_share () {
    echo
    echo "Enter your Linux account password below..."
    echo
    sudo ln -s /media/bsfnas1/brianfolder ~/$PREFIX/dosdevices/y:
    sudo mount.cifs //bsfnas1/brianfolder/ -o user=brianfolder,pass=enricocaruso,uid=$(id -u),gid=$(id -g) ~/$PREFIX/dosdevices/y:
}
echo
echo "This will mount the Samba share folder brianfolder on the bsfnas1 machine."
echo
echo
echo "== Select which WINEPREFIX you wish to use =="
echo
ls ~/.wine-* | grep .wine | awk -F'/' '{print NR " " substr($4, 1, length($4)-1)}'
NUMPREFIXES=$(ls ~/.wine-* | grep .wine | wc -l)
echo
read -p "Enter number (q to abort) and press ENTER: " CHOICE
if [ "$CHOICE" != "q" ] && [ "$CHOICE" -gt 0 ] && [ "$CHOICE" -le $NUMPREFIXES ]; then
    PREFIX=$(ls ~/.wine-* | grep .wine | awk -F'/' '{print NR " " substr($4, 1, length($4)-1)}' | grep "$CHOICE " | awk -F' ' '{print $2}')
    echo
    if [ ! -e ~/$PREFIX/dosdevices/y: ]; then
        mount_share
    else
        echo -n "~/$PREFIX/dosdevices/y: already exists. Is it OK to proceed anyway (y/n)? "
        read ANSWER
        if [ $ANSWER = "y" ]; then
            rm ~/$PREFIX/dosdevices/y:
            mount_share
        fi
    fi
    echo
fi
if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then
    echo "Samba share //bsfnas1/brianfolder is mounted for WINEPREFIX ~/$PREFIX ."
else
    echo "Samba share //bsfnas1/brianfolder is not mounted."
fi
echo
echo "You may now close this window."
read ANSWER
exit

2. Bash script ~/umount_bsfnas1_brianfolder_share.sh

#!/bin/bash
echo
echo "This will unmount the Samba share folder brianfolder on the bsfnas1 machine."
echo
echo "Enter your Linux account password below..."
echo
sudo umount ~/.wine-*/dosdevices/y: 2>/dev/null
echo
if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then
  echo "Samba share //bsfnas1/brianfolder is mounted."
else
  echo "Samba share //bsfnas1/brianfolder is not mounted."
fi
echo
echo "You may now close this window."
exit

3. Desktop Configuration file ~/Desktop/mount_bsfnas1_brianfolder_share.desktop

[Desktop Entry]
Comment[en_GB]=Mount bsfnas1 brianfolder share for current WINEPREFIX
Comment=Mount bsfnas1 brianfolder share for current WINEPREFIX
Exec=sh /home/fitzcarraldo/mount_bsfnas1_brianfolder_share.sh
GenericName[en_GB]=Mount bsfnas1 brianfolder share for current WINEPREFIX
GenericName=Mount bsfnas1 brianfolder share for current WINEPREFIX
Icon=media-mount
MimeType=
Name[en_GB]=mount_bsfnas1_brianfolder_share
Name=mount_bsfnas1_brianfolder_share
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

4. Desktop Configuration file ~/Desktop/umount_bsfnas1_brianfolder_share.desktop

[Desktop Entry]
Comment[en_GB]=Unmount bsfnas1 brianfolder share for current WINEPREFIX
Comment=Unmount bsfnas1 brianfolder share for current WINEPREFIX
Exec=sh /home/fitzcarraldo/umount_bsfnas1_brianfolder_share.sh
GenericName[en_GB]=Unmount bsfnas1 brianfolder share for current WINEPREFIX
GenericName=Unmount bsfnas1 brianfolder share for current WINEPREFIX
Icon=media-eject
MimeType=
Name[en_GB]=umount_bsfnas1_brianfolder_share
Name=umount_bsfnas1_brianfolder_share
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

Now when I double-click on the icon to mount the SMB share for a Windows application running via WINE, a terminal window pops up displaying the WINEPREFIXs currently installed on my machine:


This will mount the Samba share folder brianfolder on the bsfnas1 machine.


== Select which WINEPREFIX you wish to use ==

1 .wine-3dimviewer
2 .wine-myphoneexplorer
3 .wine-nbtscan
4 .wine-pdfxve6
5 .wine-PortableApps
6 .wine-radiant
7 .wine-symmetry
8 .wine-visio
9 .wine-xnviewmp

Enter number (q to abort) and press ENTER: 

Let’s say I want to use the Windows application XnViewMP. I would enter ‘9’ and press ‘Enter’. The rest of the interaction should be obvious:


This will mount the Samba share folder brianfolder on the bsfnas1 machine.


== Select which WINEPREFIX you wish to use ==

1 .wine-3dimviewer
2 .wine-myphoneexplorer
3 .wine-nbtscan
4 .wine-pdfxve6
5 .wine-PortableApps
6 .wine-radiant
7 .wine-symmetry
8 .wine-visio
9 .wine-xnviewmp

Enter number (q to abort) and press ENTER: 9

~/.wine-xnviewmp/dosdevices/y: already exists. Is it OK to proceed anyway (y/n)? y

Enter your Linux account password below...

[sudo] password for fitzcarraldo: 

Samba share //bsfnas1/brianfolder is mounted for WINEPREFIX ~/.wine-xnviewmp .

You may now close this window.

Henceforth the Windows application XnViewMP will be able to access the Y: drive which is actually the SMB share //bsfnas1/brianfolder.

Once I have finished using the application, I just double-click on the the icon to unmount the SMB share, and a terminal window pops up displaying the following:


This will unmount the Samba share folder brianfolder on the bsfnas1 machine.

Enter your Linux account password below...

[sudo] password for fitzcarraldo: 

Samba share //bsfnas1/brianfolder is not mounted.

You may now close this window.

Once I have entered my Linux password for the local machine, the script will unmount the SMB share and the terminal window will close automatically if you have configured the Desktop Configuration file by right-clicking on the icon and unticking ‘Do not close when command exits’ in KDE, ‘Keep terminal window open after command execution’ in LXDE, or similar in other desktop environments.

Note: If you use Microsoft Office via WINE, you also might be interested in a comment on my earlier blog post about a Microsoft Office problem in saving files to a remote SMB share.

Completing PDF forms and adding your signature without having to print the form

A recent post in the Gentoo Forums made me interested to find out what is actually achievable with fillable PDF forms in Gentoo Linux and Windows 10 without being required to purchase a software licence, be it for personal or professional use, in order to be able to complete PDF forms (including forms that have automatically-updating bar codes).

Designing PDF Forms

It is possible to create PDF forms with LibreOffice, although LibreOffice cannot create a form containing bar codes that get updated automatically with the information entered in fields on the form. In order to create PDF forms that contain automatically-updating bar codes it is necessary to purchase Adobe Acrobat DC or Adobe LiveCycle Designer, which are Windows-only applications. As forms usually have several fields, 2D bar code symbologies are used in order to be able to encode the amount of data in a practical way. See the Adobe demonstration video Capture electronic data from printed forms.

Using PDF Forms

However, the enquiry in the above-mentioned forum thread was not about designing PDF forms, it was about being able to complete existing PDF forms (including forms that have automatically-updating bar codes, and including being able to add a written signature to the form without printing it out):

Hi,

I need to sign pdfs, and sometimes fill out pdf forms which also need to be signed. At the moment I get them, print them, sign them and scan them back in to return to the sender. I’d like to simplify that.

I know that on Windows and Mac OS your adobe software can sign the pdf, but I don’t even know how that works exactly.

It would be really neat if there were an app which could handle all that.

Oh yeah, another thing. Some forms (all?) when you fill them out and print them have a bar of machine-readable gobbledygook on the page which lets the recipient of a printed pdf scan the data back in with 100% accuracy. That would be neat too.

Thanks.

Although I have sometimes added my signature to a PDF form before printing it out — more on that later — I had never come across PDF forms with automatically-updating bar codes, so my curiosity was piqued. I decided to investigate if free applications could be used to complete PDF forms (including those with automatically-updating bar codes) and add a written signature. My investigations were carried out in Linux and Windows 10, and my findings are given below. In summary, I discovered that I could do all these things in Linux as well as in Windows 10, although in Linux I had to resort to running a Windows application under WINE if a PDF form contained automatically-updating bar codes. I did not bother trying the GNOME document viewer Evince, as I could find no evidence on the Web of it having the capability of updating bar codes automatically, and I use KDE.

For my tests I used the following four PDF forms I found on the Web:

  1. acrobat8_barcodedforms.pdf, an October 2006 PDF article from Adobe containing three sample form fields and an associated automatically-updating bar code (PDF417 symbology).
  2. barcode_field.pdf, a February 2013 sample PDF form with three fields and three associated bar codes of different symbologies (PDF417, Data Matrix and QR Code).
  3. PdfFormExample.pdf, a June 2013 sample PDF form created using LibreOffice (and therefore not containing automatically-updating bar codes).
  4. sample_barcoded_demo.pdf, a December 2005 sample PDF form from Adobe with an automatically-updating bar code (PDF417 symbology).

1. Windows 10

1.1 Acrobat Reader DC

This is the ubiquitous ‘free’ closed-source application you can download from Adobe.

Below are screenshots of the four sample PDF forms opened in Acrobat Reader DC…

1.1.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf, and the bar code was updated accordingly:

Acrobat Reader DC - acrobat8_barcodedforms.pdf

Acrobat Reader DC - acrobat8_barcodedforms.pdf

I used my smartphone’s Barcode Scanner app to read the bar code on the hard-copy form printed by Acrobat Reader DC:

Text1Text2Text3I am able to change the text in these fields of this form to see how 2D barcodes work.

1.1.2 I could enter text in the three fields in barcode_field.pdf, but the three bar codes were not visible:

Acrobat Reader DC - acrobat8_barcodedforms.pdf

Acrobat Reader DC - barcode_field.pdf

1.1.3 I could enter text in the fields in PdfFormExample.pdf:

Acrobat Reader DC - PdfFormExample.pdf

Acrobat Reader DC - PdfFormExample.pdf

1.1.4 I could enter text in all fields of sample_barcoded_demo.pdf and the field contents were echoed in the box ‘Barcode Contents’ but the bar code itself was not visible:

Acrobat Reader DC - sample_barcoded_demo.pdf

Acrobat Reader DC - sample_barcoded_demo.pdf

So, in summary, Acrobat Reader DC is not a viable option if you have to deal with forms that include automatically-updating bar codes.

1.2 PDF-XChange Editor

This application from Canadian company Tracker Software Products supersedes their deprecated PDF-XChange Viewer and has additional features. Neither application is open-source, though. Some features only work fully if you purchase a software licence and enter the licence key. For example, if you add a signature to a PDF form (‘Document’ > ‘Signatures and Initials’) and then save it, DEMO stamps are added to the new PDF file (which still has editable fields). However, if you print the PDF form (either to a PDF file or to paper) then DEMO stamps are not added (but the new PDF file is not fillable/editable). Click on the two links below to view the sample PDF file PdfFormExample.pdf signed and saved to a new PDF file, and the sample PDF file PdfFormExample.pdf signed and printed to a new PDF file:

PdfFormExample_with_signature_added_then_Saved.pdf

PdfFormExample_with_signature_added_then_Printed_to_PDF.pdf

If you save them to disk and open them in PDF-XChange Editor, you will see the distinction.

As stated on the company’s Web site, the free application can be used for private and work purposes:

The FREE download of the PDF-XChange Editor may be used without limitation for Private, Commercial, Government and all uses, provided it is not: incorporated or distributed for profit/commercial gain with other software or media distribution of any type – without first gaining permission.

Below are screenshots of the four sample PDF forms opened in PDF-XChange Editor…

1.2.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf, and the bar code was updated accordingly:

PDF-XChange Editor - acrobat8_barcodedforms.pdf

PDF-XChange Editor - acrobat8_barcodedforms.pdf

I used my smartphone’s Barcode Scanner app to read the bar code on the hard-copy form printed by PDF-XChange Editor:

Text1Text2Text3
I am able to change the text in these fields of this formto see how 2D barcodes work.

Notice that the layout of the encoded text is slightly different to the bar code generated by Adobe Acrobat Reader DC.

1.2.2 I could enter text in the three fields in barcode_field.pdf, and the three bar codes were visible:

PDF-XChange Editor - barcode_field.pdf

PDF-XChange Editor - barcode_field.pdf

I used my smartphone’s Barcode Scanner app to read the three bar codes on the hard-copy form printed by PDF-XChange Editor:

The PDF417 bar code was read as follows:

text_0:PDF417 barcode:I can enter text in these fields of this form and can see the three barcodes to the right of these fields in PDF-XChange Editor.

The Data Matrix bar code was read as follows:

text_1:Data Matrix barcode:
To change the barcode field to the right, type in this box. The barcode field to the right will reflect the contents of the text field as barcode after the text field lost the focus. To reset the contents of all barcode fields, cick the ‘Rset’ button.

Notice that the words ‘click’ and ‘Reset’ in the field were apparently not encoded correctly.

The QR Code bar code was read as a meaningless apparently random bunch of characters.

The PDF file and the three bar codes were generated on the fly by PHP code calling the pdflib library produced by the company PDFlib GmbH. I do not know how accurate this particular PDF file is, or how accurate is the Bar Code Scanner app on my smartphone.

1.2.3 I could enter text in the fields in PdfFormExample.pdf:

PDF-XChange Editor - PdfFormExample.pdf

PDF-XChange Editor - PdfFormExample.pdf

1.2.4 I could enter text in all fields of sample_barcoded_demo.pdf, and the field contents were echoed in the box ‘Barcode Contents’ and the bar code itself was visible:

PDF-XChange Editor - sample_barcoded_demo.pdf

PDF-XChange Editor - sample_barcoded_demo.pdf

I used my smartphone’s Barcode Scanner app to read the PDF417 bar code on the hard-copy form printed by PDF-XChange Editor:

Brian
S
Fitzgerald
Calle Fitzcarrald, 225
Iquitos

bsf@iquitos.nom.pe

So, in summary, PDF-XChange Editor appears to be a possible option in Windows 10, whether or not you have to deal with forms that include automatically-updating bar codes. I am quite impressed with the application.

2. Linux

2.1 Acrobat Reader 9

This is the free closed-source Linux application you can install via the Portage package manager (the package is app-text/acroread).

Below are screenshots of the four sample PDF forms opened in Acrobat Reader 9 for Linux.

2.1.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf, and the bar code was updated accordingly:

Acrobat Reader 9 Linux - acrobat8_barcodedforms.pdf

Acrobat Reader 9 Linux - acrobat8_barcodedforms.pdf

I used my smartphone’s Barcode Scanner app to read the bar code on the hard-copy form printed by Acrobat Reader 9 for Linux:

Text1Text2Text3I am able to change the text in these fields of this form to see how 2D barcodes work.

2.1.2 I could enter text in the three fields in barcode_field.pdf, but the three bar codes were not visible:

Acrobat Reader 9 Linux - barcode_field.pdf

Acrobat Reader 9 Linux - barcode_field.pdf

2.1.3 I could enter text in the fields in PdfFormExample.pdf:

Acrobat Reader 9 Linux - PdfFormExample.pdf

Acrobat Reader 9 Linux - PdfFormExample.pdf

2.1.4 I could enter text in all fields of sample_barcoded_demo.pdf, and the field contents were echoed in the box ‘Barcode Contents’ but the bar code itself was not visible:

Acrobat Reader 9 Linux - sample_barcoded_demo.pdf

Acrobat Reader 9 Linux - sample_barcoded_demo.pdf

So, in summary, Acrobat Reader 9 for Linux is not a viable option if you have to deal with forms that include automatically-updating bar codes.

2.2 Okular

This is the well-known KDE document viewer application.

Below are screenshots of the four sample PDF forms opened in Okular.

2.2.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf but the bar code was not visible:

Okular - acrobat8_barcodedforms.pdf

Okular - acrobat8_barcodedforms.pdf

2.2.2 I could enter text in the three fields in barcode_field.pdf but the three bar codes were not visible:

Okular - barcode_field.pdf

Okular - barcode_field.pdf

2.2.3 I could enter text in the fields in PdfFormExample.pdf:

Okular - PdfFormExample.pdf

Okular - PdfFormExample.pdf

2.2.4 I could enter text in all fields of sample_barcoded_demo.pdf but the field contents were not echoed in the box ‘Barcode Contents’ and the bar code itself was not visible:

Okular - sample_barcoded_demo.pdf

Okular - sample_barcoded_demo.pdf

So, in summary, Okular is not a viable option if you have to deal with forms that include automatically-updating bar codes. In fact, Okular was the worst of the bunch.

2.3 PDF-XChange Editor

To install this Windows application under WINE in Linux:

$ export WINEPREFIX=$HOME/.wine-pdfxve6
$ export WINEARCH="win32"
$ winecfg # Select Windows 10.
$ cd .wine-pdfxve6/drive_c/
$ # Copy downloaded installer to C: drive:
$ cp ~/Downloads/PDFXVE6.zip .
$ unzip PDFXVE6.zip
$ # Install PDF-XChange Editor:
$ wine PDFXVE6.exe

  • Click ‘Install’.
  • Click ‘Next’.
  • Select ‘I accept the terms in the License Agreement’ and click ‘Next’.
  • Click ‘Custom’.
  • Click ‘Browsers Plugins’ and select ‘Don’t install’. Click ‘Next’.
  • Leave ‘Create a Start Menu folder’ ticked. Untick ‘Create Desktop Icons.’ Untick ‘Set PDF-XChange Editor as default application for PDF files’. Untick ‘Set Printer “PDF-XChange Lite V6” As Default’. Click ‘Next’.
  • Select ‘Free Version’ and click ‘Next’.
  • Click ‘Install’.
  • Untick ‘Launch PDF-XChange Editor’ and click ‘Finish’.
  • Click ‘Close’.

KDE Plasma 5 then has an entry for PDF-XChange Editor in the Application Launcher under ‘Applications’ > ‘Wine’ > ‘Programs’ > ‘Tracker Software’. Alternatively, to launch PDF-XChange Editor from the command line, you should enter:

$ WINEPREFIX="$HOME/.wine-pdfxve6" && WINEARCH="win32" && wine $WINEPREFIX/drive_c/Program\ Files/Tracker\ Software/PDF\ Editor/PDFXEdit.exe

If you also want the Windows application running under WINE to be able to access PDF files on a NAS, i.e. to be able to open Samba shares, see my previous post How to enable a Windows application in WINE to access a Samba share on a NAS.

I will not bother showing screenshots of the four sample PDF files open in PDF-XChange Editor running under WINE in Linux, as the application’s behaviour is the same as in Windows (see the screenshots in sections 1.2.1 to 1.2.4 above). So, in summary, PDF-XChange Editor appears to be a viable option in Linux (albeit running under WINE), irrespective of whether or not you have to deal with forms that include automatically-updating bar codes.

3. Adding a signature to a soft copy of the PDF form

I am referring to a person’s written signature here, not to a digital signature. Rather than having to print the completed form on paper in order to sign it with a pen, then scan the fully-completed form in order to send it via e-mail, fax or whatever, many people wish to add their signature directly to the PDF form without having to print it. Below I explain the method I use to do this in both Linux and Windows.

3.1 Create a PNG file with your signature (one-time operation)

  1. Get a blank white piece of paper.
  2. Sign your name on the page.
  3. Scan the page with your scanner and save the image as a PNG file.
  4. Open the image with GIMP.
  5. Crop the image around the signature.
  6. Select ‘Layer’ > ‘Transparency’ > ‘Add Alpha Channel’.
  7. Select the Fuzzy Select Tool from the toolbox.
  8. Click on each white area and press the Delete key. Do this for the area around the signature and inside any loops. Obviously don’t click on the signature itself.
  9. Select ‘File’ > ‘Export’.
  10. Save the image as a PNG file.

3.2 Signing PDF documents

  1. Launch LibreOffice Draw and open the PDF file you wish to sign.
  2. Select ‘Insert’ > ‘Image…’ and select the PNG file of your signature. The image will be inserted.
  3. To move the signature around on the page, hover the mouse cursor over the image until the cursor changes to a red dot with four arrowheads, then click-and-hold to grab the image drag it.
  4. To reduce the size of the signature, hover the mouse cursor over the image until the cursor changes to a red dot with four arrowheads, then click and release. You will then see small blue ‘handles’ on the outline of the image. Hover the mouse cursor over a handle at one of the four corners of the image until the cursor changes to a Resize cursor. Click-and-hold and move the cursor to increase or decrease the size of the signature whilst maintaining the ratio of width to height.
  5. To save the completed and signed PDF form, select ‘File’ > ‘Export as PDF…’, click on ‘Export’ and give the file a name of your choice.

The new PDF file will contain all the information visible on the previous PDF file plus your written signature. However, unlike the original PDF file, you will not be able to modify any of the data. Therefore I recommend you retain a copy of the original PDF file before you added the signature, in case you wish to change any of field entries in future.

Note that the free PDF-XChange Editor can be used instead of LibreOffice Draw providing the PDF form is not secured or restricted, and providing you print it to a new PDF file using a virtual PDF printer driver. If the PDF form is secured or changes restricted, then use LibreOffice Draw as described above.

If you are using a PDF viewer that refuses to save your completed form as a PDF file after you have entered data in the fields (notice the message in the purple bar in the screenshots of Acrobat Reader 9 for Linux, for example), print the page to a PDF file instead by using the virtual PDF printer (‘Microsoft Print to PDF’ in Windows; CUPS ‘Virtual PDF Printer’ in Linux) at a resolution of e.g. 600 dpi (if possible). You should then be able to open that PDF file in LibreOffice Draw or PDF-XChange Editor to add your signature as explained above and print the signed form to a new PDF file.

How to enable a Windows application in WINE to access a Samba share on a NAS

I recently installed the Windows application PDF-XChange Editor under WINE in Gentoo Linux on one of my laptops. The application works fine but it could not detect the SMB/CIFS (Samba) share folder on my NAS. When I clicked on ‘File‘ > ‘Open...‘ in the application, the left pane of the ‘Open Files‘ dialogue window displayed the following options:

+ Favourites
– Desktop
  + My Computer
  + My Documents
    Trash
  + /

If I clicked on ‘My Computer‘, the right pane of the dialogue window then displayed the following options:

Control Panel
(C:)
(D:)
(E:)
(F:)
(G:)
(Z:)

None of the entries in either pane enabled me to get to the Samba shares on my NAS. Anyway, it turned out to be relatively easy to configure the installation on my laptop to enable the Windows application to access the Samba shared folder on the NAS, and the basic procedure was as follows:

  1. Create a mountpoint.
  2. In the directory $WINEPREFIX/dosdevices/ create a symbolic link to the mountpoint.
  3. Mount the network share on the mountpoint.

Let’s look in detail at the procedure…

My Clevo W230SS laptop running Gentoo Linux Stable Branch amd64 currently has KDE Plasma 5.6.5 and WINE 1.9.18 installed. I had used a WINE prefix of ~/.wine-pdfxve6 to install the Windows application in the fitzcarraldo user account. Let us say that the hostname of my Linux NAS is ‘bsfnas1‘, the name of the Samba shared folder on the NAS is ‘brianfolder‘, the Samba username for that shared folder on the NAS is ‘brian‘ and the Samba share password on the NAS is ‘enricocaruso‘.

First I checked which drive letters were already being used by WINE:

$ ls -la ~/.wine-pdfxve6/dosdevices/
total 8
drwxr-xr-x 2 fitzcarraldo fitzcarraldo 4096 Sep 16 23:18 .
drwxr-xr-x 4 fitzcarraldo fitzcarraldo 4096 Sep 17 04:03 ..
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo   10 Sep 16 23:18 c: -> ../drive_c
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 d:: -> /dev/sdb1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 e:: -> /dev/sdc
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 f:: -> /dev/sdc1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 g:: -> /dev/sdb
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    1 Sep 16 23:18 z: -> /

As no Windows Y: drive was listed, I decided to use that drive letter for my network Samba share as shown in the steps below.

I created a mountpoint for the share:

$ sudo mkdir -p /media/bsfnas1/brianfolder

Then I created the symlink:

$ ln -s /media/bsfnas1/brianfolder ~/.wine-pdfxve6/dosdevices/y:
$ ls -la ~/.wine-pdfxve6/dosdevices/
total 8
drwxr-xr-x 2 fitzcarraldo fitzcarraldo 4096 Sep 17 15:38 .
drwxr-xr-x 4 fitzcarraldo fitzcarraldo 4096 Sep 17 15:39 ..
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo   10 Sep 16 23:18 c: -> ../drive_c
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 d:: -> /dev/sdb1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 e:: -> /dev/sdc
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 f:: -> /dev/sdc1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 g:: -> /dev/sdb
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo   11 Sep 17 15:37 y: -> /media/bsfnas1/brianfolder
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    1 Sep 16 23:18 z: -> /

Finally, I mounted the network share onto the symlink:

$ sudo mount.cifs //bsfnas1/brianfolder/ -o user=brian,pass=enricocarusou,id=$(id -u),gid=$(id -g) ~/.wine-pdfxve6/dosdevices/y:

As before, I see the following when I click on ‘File‘ > ‘Open...‘ in the Windows application running under WINE:

+ Favourites
– Desktop
  + My Computer
  + My Documents
    Trash
  + /

If I click on ‘My Computer‘ in the ‘Open File‘ dialogue window, the following items are displayed in the right pane of the window:

Control Panel
(C:)
(D:)
(E:)
(F:)
(G:)
(Y:)
(Z:)

and I can select the ‘(Y:)‘ and browse the contents of the shared folder brianfolder on the NAS drive.

Although I found it was unnecessary to do it for PDF-XChange Editor, apparently some Windows applications require the use of Windows UNC syntax, so I also did the following:

$ mkdir -p ~/.wine-pdfxve6/dosdevices/unc/bsfnas1
$ ln -s /media/bsfnas1/brianfolder ~/.wine-pdfxve6/dosdevices/unc/bsfnas1/brianfolder

If I wanted to unmount the Samba share explicitly, rather than leaving it to be unmounted automatically when I shutdown the laptop, I would enter the following command:

$ sudo umount ~/.wine-pdfxve6/dosdevices/y\:/

Then the Windows application on my laptop would no longer be able to browse the unmounted network share:

$ ls ~/.wine-pdfxve6/dosdevices/
c:  d::  e::  f::  g::  unc  y:  z:
$ ls -la /media/bsfnas1/brianfolder
total 8
drwxr-xr-x 2 root root 4096 Sep 17 15:35 .
drwxr-xr-x 4 root root 4096 Sep 17 15:35 ..
$

You may be wondering why I did not add an entry in the file /etc/fstab on my laptop, to mount the Samba share automatically when I boot the laptop. The reason I didn’t is because I often use the laptop away from home and the NAS on my home network is then inaccessible in any case. However, to save myself the hassle of having to enter the mount command manually when I am at home and want to use the Windows application to open a file that is in the NAS shared folder, I created two Desktop Configuration files named mount_bsfnas1_brianfolder_share.desktop and umount_bsfnas1_brianfolder_share.desktop with nice icons in my ~/Desktop directory on the laptop:

[Desktop Entry]
Comment[en_GB]=Mount bsfnas1 brianfolder share for PDF-XChange Editor
Comment=Mount bsfnas1 brianfolder share for PDF-XChange Editor
Exec=sh /home/fitzcarraldo/mount_bsfnas1_brianfolder_share.sh
GenericName[en_GB]=Mount bsfnas1 brianfolder share for PDF-XChange Editor
GenericName=Mount bsfnas1 brianfolder share for PDF-XChange Editor
Icon=media-mount
MimeType=
Name[en_GB]=mount_bsfnas1_brianfolder_share
Name=mount_bsfnas1_brianfolder_share
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

[Desktop Entry]
Comment[en_GB]=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
Comment=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
Exec=sh /home/fitzcarraldo/umount_bsfnas1_brianfolder_share.sh
GenericName[en_GB]=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
GenericName=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
Icon=media-eject
MimeType=
Name[en_GB]=umount_bsfnas1_brianfolder_share
Name=umount_bsfnas1_brianfolder_share
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

and the Bash scripts mount_bsfnas1_brianfolder_share.sh and umount_bsfnas1_brianfolder_share.sh launched by the above two Desktop Configuration files are, respectively:

#!/bin/bash
echo "This will mount the Samba share folder brianfolder on the bsfnas1 machine."
echo
echo "Enter your Linux account password below..."
echo
sudo mount.cifs //bsfnas1/brianfolder/ -o user=brian,pass=enricocaruso,uid=$(id -u),gid=$(id -g) ~/.wine-pdfxve6/dosdevices/y:
echo
if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then
  echo "Samba share //bsfnas1/brianfolder is mounted."
else
  echo "Samba share //bsfnas1/brianfolder is not mounted."
fi
echo
echo "You may now close this window."

#!/bin/bash
echo "This will unmount the Samba share folder brianfolder on the bsfnas1 machine."
echo
echo "Enter your Linux account password below..."
echo
sudo umount ~/.wine-pdfxve6/dosdevices/y:
echo
if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then
  echo "Samba share //bsfnas1/brianfolder is mounted."
else
  echo "Samba share //bsfnas1/brianfolder is not mounted."
fi
echo
echo "You may now close this window."

Don’t forget to make the two shell scripts executable:

$ chmod +x /home/fitzcarraldo/mount_bsfnas1_brianfolder_share.sh
$ chmod +x /home/fitzcarraldo/umount_bsfnas1_brianfolder_share.sh

If I was doing this on a desktop PC instead of a laptop, instead of creating the above-mentioned .desktop files and Bash scripts I would have added the following line in the file /etc/fstab to mount the NAS Samba shared folder automatically at boot:

//bsfnas1/brianfolder  /media/bsfnas1/brianfolder  cifs  rw,iocharset=utf8,user=brian,pass=enricocaruso  0   0

It works (I’ve tried it).

Further reading
WineHQ Forums – Mapped network drive in wine.
Estendendo suporte a UNC no Wine.

WINE tips: File associations of Windows applications in Linux

I have several applications for Windows installed under WINE in Linux. These applications launch correctly if I double-click on a file for that application, but, in the case of some of these applications, the file itself is not opened. Therefore I first have to launch the application and then load the file from within the application (File > Open, or whatever). Some time ago I explained how to fix this in the case of IrfanView by creating a shell script – see my post WINE tips: How to associate IrfanView with an image file type in Linux – but there is an easier way to do it in many cases, as illustrated by the example below for another Windows application I use regularly in Linux. I finally got fed up with not being able to open .vsd (Visio drawing) files by double-clicking on them in Linux, and decided to fix this. The same procedure applies, whatever the Windows application.

I use KDE, but the principle applies whatever Desktop Environment you are using. Just use the relevant File Association configuration tool for that Desktop Environment.

  1. I selected ‘System Settings’ > ‘File Associations’ from the KDE Kickoff menu launcher.

  2. I entered ‘vsd’ (without the quotes) in the search field in order to find the application associated with that file type.

    The ‘Known Types’ box then displayed the following:

    >- application

  3. When I expanded that by clicking on it, the ‘Known Types’ box displayed the following two application file types:

    v- application
            vnd.ms-visio.viewer
            vnd.visio

  4. Clicking on either displayed ‘Visio 5.0 Professional’ in the ‘Application Preference Order’ box. I selected it and clicked on ‘Edit…’, which opened a Properties window for the application’s desktop configuration file.

  5. I clicked on the ‘Application’ tab. The ‘Command’ box contained the following command:
    env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine /home/fitzcarraldo/.wine-visio5/drive_c/Program\ Files/Visio/Visio32.EXE

    (The wine command itself has to be preceded by the definition of the WINEPREFIX and WINEARCH environment variables because I specified those environment variables originally when I installed the application via WINE.)

    I changed the command to be the following:

    env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix %U

    for both vnd.ms-viso.viewer and vnd.visio application file types, and clicked on ‘OK’ and ‘Apply’.

That’s all there was to it. Now when I double-click on any file ending with ‘.vsd’, Visio launches as before but the actual file is opened in the application. Very straightforward, and I really should have made the effort to fix it sooner. 🙂

Installing Firefox for Windows and the Silverlight plug-in in WINE

I use 64-bit (~amd64) multilib Gentoo Linux on my main laptop, and had been using successfully Version 0.2.3 of the Pipelight browser plug-in in 64-bit Firefox 29.0.1 for Linux to access an office Intranet Web site that uses Microsoft Silverlight. However, after installing 64-bit Firefox 30.0 for Linux recently I found that Mozilla has removed NPAPI support by default in Firefox 30, and Web sites using Silverlight would no longer load.

By updating Pipelight to Version 0.2.6 and changing the user agent string — see ‘Firefox UserAgent Switcher list‘ — I was able to browse in Firefox 30.0 for Linux only some of the Web sites that use Silverlight, but the aforementioned Intranet Web site would no longer load and displayed the following error message instead:

It appears the browser you are using to access this site is unsupported. Please use one of the following browsers …

· Internet Explorer 8.0

· Internet Explorer 9.0

· Internet Explorer 10.0

If you are using one of these browsers and you are still seeing this message, please contact company support.

I tried changing Firefox’s user agent string to the following, which I found from the post ‘Firefox UserAgent Switcher list‘:

Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0

That user agent string allowed the Intranet’s Web page to start loading, but a window popped-up displaying the error message shown below and Firefox stopped responding (froze).

Error reading Localization file

[Xml_UnexpectedTokens2]
Arguments: Content-Type,”,’,4,18
Debugging resource strings unavailable. Often the key and arguments provide
sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?
linkid=106663&Version=5.1.30214.00&File=System.Xml.dll&Key=Xml_UnexpectedTokens2

After trying various user agent strings without success I decided to install 64-bit Firefox 30.0 for Windows and the 64-bit Silverlight plug-in in WINE. The 64-bit Firefox 30.0 for Windows installed successfully and I could launch it and browse the Internet. However, I found that the 64-bit Silverlight plug-in would not install (according to a message in the Silverlight Installer window, installation of the plug-in crashed at 82% complete), so I then installed 32-bit Firefox 30.0 for Windows with the 32-bit Silverlight plug-in, and that worked. Below I list the steps I used to install and configure 32-bit Firefox 30.0 with the 32-bit Silverlight plug-in in WINE (which, in my installation, was compiled to support both 32-bit and 64-bit Windows applications).

Installation and configuration of 32-bit Firefox for Windows and the Silverlight plug-in

1. I used a Web browser to download the file ‘Firefox Setup 30.0.exe‘ from the Mozilla Firefox Web site to the /home/fitzcarraldo/Downloads/ directory. The Mozilla Web site offers a choice of localised versions, so I downloaded the installer for Firefox for Windows in British English.

2. I opened a Konsole window and entered the following commands:

$ cd
$ export WINEPREFIX=$HOME/.wine-firefox
$ export WINEARCH="win32"
$ winecfg # Set Windows Version to Window 7.
$ cd ./.wine-firefox/drive_c/
$ wget http://winetricks.org/winetricks # Download winetricks so I can install Windows fonts.
$ chmod +x winetricks # Make winetricks script executable.
$ ./winetricks # Launch winetricks and install Windows fonts.
$ cp /home/fitzcarraldo/Downloads/Firefox\ Setup\ 30.0.exe .
$ wine Firefox\ Setup\ 30.0.exe
$ env WINEPREFIX="/home/fitzcarraldo/.wine-firefox" WINEARCH="win32" wine /home/fitzcarraldo/.wine-firefox/drive_c/Program\ Files/Mozilla\ Firefox/firefox.exe # Launch Firefox and download the Silverlight installer.

N.B. Keep the Konsole window open and use it to enter all the commands listed in this post.

Notice that I downloaded and launched the excellent winetricks script so that I could install some Windows fonts that Firefox for Windows might need to use. When the winetricks window opens, all I needed to do was:

  • Select ‘Select the default wineprefix’ and click ‘OK’
  • Select ‘Install a font’and click ‘OK’.
  • Select ‘allfonts’ and click ‘OK’.
  • Optionally, if you have an LCD monitor and you would like to enable subpixel font smoothing, select ‘Change Settings’ then ‘fontsmooth=rgb’ and click ‘OK’.

3. I used the 32-bit Firefox for Windows Web browser to download the Silverlight plug-in installer to the /home/fitzcarraldo/Downloads/ directory. The files downloaded were Silverlight.exe and Silverlight.exe:Zone.Identifier which were both downloaded when I clicked on the ‘Click to Install’ button on the ‘Get Microsoft Silverlight‘ Web page and I then moved them from the directory /home/fitzcarraldo/Desktop/ to the /home/fitzcarraldo/Downloads/ directory.

4. I exited Firefox for Windows and installed the Silverlight plug-in:

$ cp /home/fitzcarraldo/Downloads/Silverlight* .
$ wine Silverlight.exe # Now install 32-bit Silverlight.

5. Then I launched Firefox for Windows again to configure the User Agent:

$ env WINEPREFIX="/home/fitzcarraldo/.wine-firefox" WINEARCH="win32" wine /home/fitzcarraldo/.wine-firefox/drive_c/Program\ Files/Mozilla\ Firefox/firefox.exe

I entered ‘about:config‘ (without the quotes) in the Address bar and added a new preference named general.useragent.override containing the following string (it is a User Agent string for Microsoft Internet Explorer 10.6 in 32-bit Windows 7):

Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0

N.B. This is the user agent string I used to get a specific office’s Intranet Web site that uses Silverlight to load in the Firefox 30.0 for Windows browser. You may need to use a different user agent string for the particular Web site you want to load. Use a search engine to search the Web for suitable user agent strings for the specific Web site you wish to browse. I have seen various user agent strings given for Netflix, for example, so you may have to try several to find one that works for you.

Alternatively, rather than using about:config you could install a Firefox extension such as User Agent Switcher and the associated ‘useragentswitcher.xml‘ file (see the ‘Firefox UserAgent Switcher list’ reference above for details of how to install), which would allow you to add, edit and select user agent strings more easily. An alternative to User Agent Switcher is the Firefox extension User Agent Overrider which may give you better results than User Agent Switcher on some Web sites that use Silverlight. I have tried it and it enables me to view the Silverlight test pages on the Web (I selected ‘Windows / Firefox 29’ from the User Agent Overrider pull-down menu).

6. I also made sure that plugins.click_to_play is set to ‘true’ (it should be by default) and I gave permission to Firefox to use the Silverlight plug-in on the relevant Web site I wish to use (Open menu > Add-ons > Plugins). See ‘Issues related to plugins – 4.1 Click to Play in Mozilla browser versions 23 and above‘ on the mozillaZine Website and ‘How to always activate a plugin for a trusted website‘ on the Mozilla Support Website.

Launching Firefox for Windows correctly in Linux

To launch Firefox for Windows from the command line you will need to enter either of the following commands:

$ env WINEPREFIX="/home/fitzcarraldo/.wine-firefox" WINEARCH="win32" wine /home/fitzcarraldo/.wine-firefox/drive_c/Program\ Files/Mozilla\ Firefox/firefox.exe

$ env WINEPREFIX="/home/fitzcarraldo/.wine-firefox" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-firefox/dosdevices/c:/users/Public/Start\ Menu/Programs/Mozilla\ Firefox.lnk

Alternatively, you can set up a Desktop Configuration File (.desktop file) on your Desktop and/or an entry in the Desktop Environment’s launcher menu. In my case, WINE took care of doing both of those during the installation of Firefox for Windows, and it used the standard Firefox icon. I just needed to edit the entry’s command for launching Firefox, to make it match one of the commands listed above.

Postscript

Regarding the file Silverlight.exe:Zone.Identifier that was downloaded when I downloaded the Silverlight installer (Silverlight.exe), I had never come across such a file type before but have now found out what it is:

File that contains metadata describing the security zones associated with another file; generated automatically when a file is downloaded from the Internet or received as an email attachment; often created by Internet Explorer.

See the article .ZONE.IDENTIFIER File Extension for details.

You can therefore forget about the Silverlight.exe:Zone.Identifier file (if one even exists in your case). The important thing is to download the Silverlight installer, which is a single .exe file.

Installing the Windows version of Google Earth in WINE

Some Gentoo Linux users have reported that, although the native Linux release of Google Earth crashes, they can run the Windows version successfully under WINE. However, those users have also reported that the Windows installer for Google Earth did not work under WINE and so they copied the C:\Program Files\Google\Google Earth\ directory from a Windows PC to the virtual C:\ drive in their .wine directory (it would be ‘Program Files (x86)‘ in a 64-bit Windows installation, as Google Earth is a 32-bit application).

Now, if you download the Windows Google Earth installer from the Google Web site, what you get is a file GoogleEarthWin.exe that is 534.6 KiB in size (the size may vary depending on the release). However, you can instead download the Offline Installer using the following URL:

http://dl.google.com/earth/client/advanced/current/GoogleEarthWin.exe

and then you get a file GoogleEarthWin.exe that is 24.3 MiB in size (the size will vary depending on the release), which does run in WINE and does install the Windows version of Google Earth in WINE.

So, you might like to try that if you cannot run Google Earth in Linux but you have WINE installed. However, note that you will be wasting your time if the native Linux version of Google Earth crashes because of its incompatibility with the closed-source ATI or NVIDIA video driver. For example, Google Earth 7.1.2.2041 for Linux crashes on my main laptop using the 14.3_beta version of ati-drivers (AMD ATI Catalyst driver, a.k.a. FGLRX).

Anyway, if you want to install the Windows release of Google Earth under WINE here’s how to do it in a Konsole/Terminal window:

$ cd
$ export WINEPREFIX=$HOME/.wine-googleearth
$ export WINEARCH="win32"
$ winecfg
$ cd ./.wine-googleearth/drive_c/
$ wget http://dl.google.com/earth/client/advanced/current/GoogleEarthWin.exe
$ wine GoogleEarthWin.exe

And, to run it later:

$ env WINEPREFIX="/home/fitzcarraldo/.wine-googleearth" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-googleearth/dosdevices/c:/users/fitzcarraldo/Start\ Menu/Programs/Google\ Earth/Google\ Earth.lnk

(Of course replace “fitzcarraldo” with your user name.)

But, as I wrote above, if the native Linux version of Google Earth crashes due to its incompatibility with the closed-source video driver (ATI or NVIDIA), it is highly unlikely the native Windows version will work under WINE.

Editing from a Linux PC the phone book (contacts list) in an Android phone

A mobile phone stores contacts in the phone itself and/or on the SIM. Over the years, the phone book on my SIM became cluttered with duplicate entries, inconsistently-named contacts, and so on. I decided recently to tidy up the phone book, and looked for a way to do it from Linux.

Now, the last time I tidied up my phone book was back in 2003 when my SIM was in a Sony Ericsson T68i. These days I’m using the same SIM in an Android smartphone: the HTC Desire. Back then I used a shareware application called Mobile Navigator on a laptop running Windows XP. So, naturally, I thought it would be possible to do something similar from a PC running Linux.

An indirect method of editing a phone book in an Android phone is recommended in many Web forums. The advice is to synchronise the phone’s phone book with GMail on your PC, edit the contacts in GMail on the PC and then the contacts will be updated in the phone when the phone next synchronises with GMail. That is all very well, but I don’t want to import my phone contacts into GMail and thus have them stored in ‘The Cloud’, plus I don’t see why I should be forced to do that just to make it easier for me to tidy a phone book in my phone. So I set about searching for an application to do the job.

My search turned up three applications that appeared to enable a user to edit the phone book (phone and SIM):

1. Gammu (CLI) and Wammu (GUI front-end), FOSS with versions for both Linux and Windows.

2. MOBILedit!, a closed-source commercial product for Windows.

3. MyPhoneExplorer (Version 1.8.1), closed-source ‘donationware’ for Windows, recommended in various forums and that has been used with WINE in Linux. Not only does MyPhoneExplorer allow you to edit the phone book, it also provides a host of other features such as: viewing the phone’s call logs, messages, hardware status, files and applications; sending messages via the PC; etc. It’s a nifty application.

Web browsing told me that Gammu/Wammu does not yet work with the HTC Desire (see the bug report Don’t get any connection to HTC Desire via bluetooth in Wammu/Gammu). This is a pity, as Wammu and Gammu look well-designed, and Wammu has a professional feel to it.

The price for MOBILedit! is not extortionate but I wanted to find a cost-free solution if possible, and, more importantly, I could find no evidence on the Web of MOBILedit! having been used with WINE in Linux to edit the phone books in the HTC Desire.

The MyPhoneExplorer forums include a thread on using it with WINE, so MyPhoneExplorer looked like my only option (although it is a pity it is not FOSS). I installed MyPhoneExplorer with its own WINEPREFIX but, despite following the instructions in the MyPhoneExplorer forums, I was unable to get MyPhoneExplorer to connect to the HTC Desire via a USB cable in Linux. This may be because, despite what I have read on the android developers Web site (see Using Hardware Devices and OEM USB Drivers), as is the case with Windows it is necessary in Linux to install ADB USB drivers (the ADB drivers can be installed in Linux by installing the Android SDK). However, I was able to connect MyPhoneExplorer to my HTC Desire via WiFi at home (but not in a hotel, as connection depends on the router and internal network IP address space), and via Bluetooth (anywhere).

How to install MyPhoneExplorer in WINE

1. Use the Android Market to install MyPhoneExplorer Client on the phone.

2. Surf over to the MyPhoneExplorer Home Page and download MyPhoneExplorer_Setup_1.8.1.exe to ~/Desktop/

3. Open a Konsole/Terminal window and perform all the following steps in the same window.

4. Install MyPhoneExplorer on your PC under WINE:

$ cd
$ export WINEPREFIX=$HOME/.wine-myphoneexplorer
$ export WINEARCH="win32"
$ winecfg
$ wget "http://download.microsoft.com/download/5/a/d/5ad868a0-8ecd-4bb0-a882-fe53eb7ef348/VB6.0-KB290887-X86.exe"
$ wine VB6.0-KB290887-X86.exe
$ cd ./.wine-myphoneexplorer/drive_c/
$ cp $HOME/Desktop/MyPhoneExplorer_Setup_1.8.1.exe .
$ mv ${WINEPREFIX}/drive_c/windows/system32/oleaut32.dll ${WINEPREFIX}/drive_c/windows/system32/oleaut32-alt.dll
$ mv ${WINEPREFIX}/drive_c/windows/system32/olepro32.dll ${WINEPREFIX}/drive_c/windows/system32/olepro32-alt.dll
$ echo -e REGEDIT4\\n\\n[HKEY_CURRENT_USER\\Software\\Wine\\DllOverrides]\\n\"asycfilt\"=\"native\"\\n\"comcat\"=\"native\"\\n\"msvbvm60\"=\"native\"\\n\"oleaut32\"=\"native\"\\n\"oleaut32\"=\"native\"\\n\"olepro32\"=\"native\"\\n\"stdole2.tlb\"=\"native\"\\n[HKEY_CURRENT_USER\\Software\\MyPhoneExplorer]\\n\"Language\"=\"English.lng\" > temp.reg
$ wine regedit temp.reg
$ wget http://www.kegel.com/wine/winetricks
$ chmod +x winetricks
$ ./winetricks # Install Visual Basic 6 SP6 (I had to do this as well as wine VB6.0-KB290887-X86.exe)
$ ./winetricks # Install msxml3
$ wine MyPhoneExplorer_Setup_1.8.1.exe # Install MyPhoneExplorer

(Make sure you select the WINEPREFIX first when using winetricks)

5. Edit your Desktop Environment’s menu to use the following command for launching MyPhoneExplorer:

env WINEPREFIX="/home/fitzcaraldo/.wine-myphoneexplorer" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-myphoneexplorer/dosdevices/c:/users/Public/Start\ Menu/Programs/MyPhoneExplorer/MyPhoneExplorer.lnk

(Of course replace “fitzcarraldo” with your user name.)

How to connect via Bluetooth

1. Look up the phone’s Bluetooth MAC address in the phone itself, write it down and keep it to hand. (I use the MAC address 11:22:33:AA:BB:C1 in the examples below.)

2. Enable Blutooth on your PC and phone, make them both discoverable, and pair them.

3. Launch MyPhoneExplorer Client on the phone and wait a few seconds for it to load and run.

4. Now check which channel is used by MyPhoneExplorer Client (In the example below it is Channel 17):

$ sudo sdptool browse
Inquiring ...
Browsing 11:22:33:AA:BB:C1 ...
Service RecHandle: 0x10000
Service Class ID List:
"PnP Information" (0x1200)

Service Name: Headset Gateway
Service RecHandle: 0x10001
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0100

Service Name: Handsfree Gateway
Service RecHandle: 0x10002
Service Class ID List:
"Handsfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105

Service Name: Object Push
Service RecHandle: 0x10003
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100

Service RecHandle: 0x10004
Service Class ID List:
"AV Remote Target" (0x110c)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x100
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0100

Service Name: BRCM Advanced Audio
Service RecHandle: 0x10005
Service Class ID List:
"Audio Source" (0x110a)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 25
"AVDTP" (0x0019)
uint16: 0x102
Profile Descriptor List:
"Advanced Audio" (0x110d)
Version: 0x0102

Service Name: Phonebook Access PSE
Service RecHandle: 0x10006
Service Class ID List:
"Phonebook Access - PSE" (0x112f)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 4
"OBEX" (0x0008)
Profile Descriptor List:
"Phonebook Access" (0x1130)
Version: 0x0100

Service Name: OBEX File Transfer
Service RecHandle: 0x10007
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 5
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX File Transfer" (0x1106)
Version: 0x0100

Service Name: MyPhoneExplorer
Service RecHandle: 0x10008
Service Class ID List:
UUID 128: 00001101-0000-1000-7000-00304b7f34de
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 17

5. Bind a virtual serial device to the phone (You can look up the phone’s Bluetooth MAC address in the phone itself to double check):

$ sudo rfcomm bind 1 11:22:33:AA:BB:C1 17

N.B. If you have been tinkering already with binding, and the virtual device /dev/rfcomm1 is therefore already bound, you will get an error message saying “Can't create device: Address already in use“. You can release the virtual device by using the command:

$ sudo rfcomm release /dev/rfcomm1

6. Create a symbolic link for the virtual serial link:

$ export WINEPREFIX=$HOME/.wine-myphoneexplorer
$ sudo ln -is /dev/rfcomm1 ${WINEPREFIX}/dosdevices/com2
$ sudo chmod 777 ${WINEPREFIX}/dosdevices/com2 # you may not need to do this, as the permissions may already be 777.

7. Launch MyPhoneExplorer (e.g. in KDE this would be: Kickoff > Applications > Wine> Programs > MyPhoneExplorer > MyPhoneExplorer), then press F2 (or select File > Settings).

8. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘SonyEricsson phone with modeminterface’. Tick ‘Stable connection (some features are deactivated)’.

9. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘Phone with Google Android-OS’.

10. Select ‘Connection’ in the left pane and then select ‘Connect via…’ to be ‘Bluetooth’ and enter “COM2” (upper case, and without the quotes) and click on ‘OK’.

11. Press F1 (or select File > Connect) and your PC should be able to connect to the phone and synchronise with your phone’s phone book (Extras > Start Multi-sync), thus enabling you to edit the contents and re-synchronise to update the phone book in the phone.

Script to make subsequent connections via Bluetooth easier

Note that the channel used by MyPhoneExplorer Client will change the next time you want to connect, so there is no point editing /etc/bluetooth/rfcomm.conf (the Linux configuration file in which you would normally specify the channel). Therefore, to make life a little easier, I wrote a simple Bash script to automate as much as possible the process of reconnecting via Bluetooth in future. If you want to do the same, use your favourite text editor and save the following script with the file name myphoneexplorer.sh:

#!/bin/bash
echo -n "Please switch on Bluetooth via System Tray icon, make Bluetooth discoverable then press ENTER: "
read RESPONSE
echo -n "Please enable Bluetooth on the phone, make it discoverable then press ENTER: "
read RESPONSE
export WINEPREFIX="/home/fitzcarraldo/.wine-myphoneexplorer"
export WINEARCH="win32"
echo "Checking current rfcomm status..."
sudo rfcomm -a
echo "Trying to release rfcomm1 in case it is in use (no message means rfcomm1 is released and is now OK to use,"
echo "and the message Cannot release device: No such device also means rfcomm1 is OK to use)..."
sudo rfcomm release /dev/rfcomm1
echo -n "Now please launch MyPhoneExplorer Client on the phone, wait a few seconds then press ENTER: "
read RESPONSE
echo "Find channel of MyPhoneExplorer Client:"
sudo sdptool browse
echo -n "Enter the channel number: "
read RESPONSE
sudo rfcomm bind 1 11:22:33:AA:BB:C1 $RESPONSE
echo "Checking current rfcomm status..."
sudo rfcomm -a
echo "If all is OK then please launch MyPhoneExplorer from Kickoff > Applications > Wine > Programs > MyPhoneExplorer"
echo "and press F1 to connect to the phone."

(Of course replace “fitzcarraldo” with your user name, and replace “11:22:33:AA:BB:C1” with the Bluetooth MAC address of your phone.)

Then make the script executable:

$ chmod +x myphoneexplorer.sh

The next time you want to use MyPhoneExplorer, open a Konsole/Terminal, execute the script:

$ sh myphoneexplorer.sh

and follow the instructions it displays in the Konsole/Terminal window.

How to connect via WiFi

Connecting MyPhoneExplorer to the phone via WiFi is easier than via Bluetooth. Note that WiFi connection will not work with a public WiFi network, just a home WiFi network.

1. Enable WiFi on your PC and phone.

2. Launch MyPhoneExplorer Client on the phone and wait a few seconds for it to load and run.

3. Launch MyPhoneExplorer (e.g. in KDE this would be: Kickoff > Applications > Wine> Programs > MyPhoneExplorer > MyPhoneExplorer), then press F2 (or select File > Settings).

4. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘SonyEricsson phone with modeminterface’. Tick ‘Stable connection (some features are deactivated)’.

5. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘Phone with Google Android-OS’.

6. Select ‘Connection’ in the left pane and then select ‘Connect via…’ to be ‘WiFi’ and click on ‘OK’.

7. Press F1 (or select File > Connect) and your PC should be able to connect to the phone and synchronise with your phone’s phone book (Extras > Start Multi-sync), thus enabling you to edit the contents and re-synchronise to update the phone book in the phone.

Useful references

The MyPhoneExplorer forums are oriented to Windows as it is a Windows application, but there is a thread for Linux users: HowTo: Use MyPhoneExplorer under GNU/Linux (English Version)

The thread for Windows users of MyPhoneExplorer may also be of some use: Howto and FAQ: Use Android Phones with MyPhoneExplorer

Limitations in WINE

The only limitation I have found using MyPhoneExplorer 1.8.1 in WINE is that it crashes if I try to cut and paste when editing a phone book entry. Additionally, some people have reported that the buttons on the button bar do not work when you are connected to the phone; they usually do work for me (apparently it depends on whether you have installed msxml3) but sometimes don’t. In any case, if they don’t then you can use the pull-down menus from the menu bar instead.

Other than that, MyPhoneExplorer works well in WINE and enables me to edit the phone book in my Android phone without involving Big Brother! It’s a nice application.

Firewall rules if using WiFi

If you’re using MyPhoneExplorer to connect with the phone via WiFi instead of Bluetooth, and your PC has a firewall enabled, according to a post on 7 June 2011 in the MyPhoneExplorer forums you have to configure the firewall with the following rules:

TCP port 80 (outgoing) – Check for update
TCP port 5210 (outgoing) – Communication with client
UDP port 5211 (outgoing) – Communication with client
UDP port 5212 (inbound) – Broadcast from the client

Below I list the rules I implemented in Uncomplicated Firewall:

# ufw status
Status: active

To              Action          From

--              ------          ----
Anywhere        ALLOW           5212/udp

80/tcp          ALLOW OUT       Anywhere
5210/tcp        ALLOW OUT       Anywhere
5211/udp        ALLOW OUT       Anywhere

Alternatively you could just disable the firewall on your PC while you’re using MyPhoneExplorer with your phone, which I do anyway when I’m at home as my home network is protected by the firewall in my router.

EDIT (October 25, 2012): Now there is another way of editing an Android phone’s contacts list from Linux: AirDroid. And you don’t need to mess around with WINE to use it. For details see my post AirDroid, a handy Android app for managing your phone from Linux.

How to play MSS2 codec (Windows Media Video 9 Screen) .wmv files in 64-bit Linux

One type of legacy .wmv file uses the ‘Windows Media Video 9 Screen’ MSS2 codec (“DMO-based codec, optimized for low-bitrate sequential screen captures or screencasts”, according to Wikipedia). Now, it is not possible to use win32codecs with the 64-bit versions of Linux multimedia players, so they cannot play .wmv files that use the MSS2 codec. However, there is a way around this: use the Windows version of SMPlayer in WINE. Below I explain the procedure I used to enable me to play .wmv files that use the MSS2 codec.

1. I surfed over to the download page of the MPlayer Web site and downloaded to ~/Desktop/ the installer for the latest version of SMPlayer for Windows (smplayer-0.6.9-win32.exe at the time of writing).

2. I configured WINE and installed SMPlayer for Windows:

$ cd
$ export WINEPREFIX=$HOME/.wine-smplayer
$ export WINEARCH="win32"
$ winecfg
$ cd .wine-smplayer/drive_c/
$ cp ~/Desktop/smplayer-0.6.9-win32.exe .
$ wine smplayer-0.6.9-win32.exe

3. I launched SMPlayer for Windows:

As I had opted to use a WINEPREFIX, to launch SMPlayer (Windows version) from the command line I would need to enter the following command under my normal user account:

env WINEPREFIX="/home/fitzcarraldo/.wine-smplayer" WINEARCH="win32" wine /home/fitzcarraldo/.wine-smplayer/drive_c/Program\ Files/SMPlayer/smplayer.exe

Instead it was easier for me to edit the Desktop Configuration File that was created on the Desktop, and also edit the menu entry that was created in the Kickoff menu, to execute the above command for me. Now all I need to do to launch SMPlayer for Windows is either to select it from Kickoff > Applications > Wine > Programs > SMPlayer > SMPlayer or to double-cick on the SMPlayer for Windows icon on my Desktop.

EDIT (December 11, 2012): OK, for those of you having trouble seeing the video component and only hearing the audio component of a .wmv file using MSS2, you need to do the following:

When you launch the SMPlayer 0.6.9 Setup program (wine smplayer-0.6.9-win32.exe) and click on Next and accept the Licence Agreement, make sure Binary Codecs (under MPlayer Components) is ticked.

When you launch SMPlayer for Windows and open the .wmv file, click on Options > Preferences to open the Preferences window. Click on General in the left pane, then click on the Video tab in the main pane and select “directx (fast)” or “directx(slow)” as the Output driver. I have just done this again (I’m currently using WINE 1.5.18) and I’m watching a MSS2-encoded .wmv file ‘Kai_Software2.wmv‘ as I type this, as shown in the information listed by SMPlayer for Windows:

Kai_Software2.wmv
General
File H:/Kai_Software2.wmv
Size 3193 KB (3 MB)
Length 00:04:33
Demuxer asf

Video
Resolution 883 x 720
Aspect ratio 1.22639
Format MSS2
Bitrate 100 kbps
Frames per second 1000.000
Selected codec wmsdmod

Initial Audio Stream
Format 353
Bitrate 16 kbps
Rate 22050 Hz
Channels 1
Selected codec ffwmav2

Audio Streams
# 0
Language
Name
ID 1

Just to recap:

$ cd
$ export WINEPREFIX="/home/fitzcarraldo/.wine-smplayer"
$ export WINEARCH="win32"
$ winecfg
$ cd /home/fitzcarraldo/.wine-smplayer/drive_c/
$ cp ~/Downloads/smplayer-0.6.9-win32.exe ~/.wine-smplayer/drive_c/
$ wget http://winetricks.org/winetricks
$ chmod +x ./winetricks
$ ./winetricks # 'Select the default wineprefix' + OK first then 'Install a Windows DLL or component' + OK and tick 'allcodecs' and OK.
$ wine smplayer-0.6.9-win32.exe # Make sure Binary Codecs is ticked.

WINE tips: How to associate IrfanView with an image file type in Linux

In my previous post I showed how to install IrfanView with a WINEPREFIX. This time I’m going to show you how to associate IrfanView with a particular image file type so that IrfanView launches and opens a file of that type when you double-click on the file.

IrfanView is an excellent free (but not open-source) application for Windows, and I’ve been using it in Windows since 1997. But there are so many excellent image viewing and editing applications native to Linux that I’ve never needed or wanted to install IrfanView under WINE. GQview, Gwenview, KolourPaint and the GIMP have so far covered all my needs. Nevertheless, IrfanView is my favourite utility for viewing and manipulating image files in Windows, and I can understand why some people may want to run it in Linux.

The usual method of setting file associations in Linux does not work for IrfanView. For example, if you use KDE’s Kickoff > System Settings > File Associations to associate JPG files with IrfanView, IrfanView will indeed launch if you double-click on a JPG file, but you’ll be left staring at an empty IrfanView window, as if you had simply launched IrfanView directly.

However, there is a straightforward work-around for this problem, and it involves the use of a Bash script. You associate the file type with a Bash script that you create specifically to accept a Linux parameter for the file name and convert it to a format that WINE can pass to IrfanView when launching it. Here is how to do it.

I created a text file ~/launch_IrfanView.sh containing the following Bash script:

#!/bin/sh
File="z:"${1//\//\\}
wine "/home/fitzcarraldo/.wine-irfanview/drive_c/Program Files/IrfanView/i_view32.exe" $File

I used a WINEPREFIX of $HOME/.wine-irfanview/ when I installed IrfanView, so replace “.wine-irfanview” with “.wine” if you installed IrfanView without a WINEPREFIX (i.e. if it is installed in the ~/.wine/ directory tree).

I made the file executable:

$ chmod +x /home/fitzcarraldo/launch_IrfanView.sh

I then edited the command for ‘IrfanView 4.27’ in ‘Kickoff’ > ‘System Settings’ > ‘File Associations’ > ‘image’ > ‘jpeg’ > ‘Application Preference Order’ | ‘IrfanView 4.27’ > ‘Edit’ > ‘Application’ to be as follows:

/home/fitzcarraldo/launch_IrfanView.sh %f

That works fine: when I double-click on a JPG file in a Dolphin window, IrfanView launches and opens the file.

Of course, if you want IrfanView to be the default viewer for PNG files then you would perform the aforementioned steps for ‘Kickoff’ > ‘System Settings’ > ‘File Associations’ > ‘image’ > ‘png’.

As I wrote initially, there are several excellent image viewers and editors for Linux, so I did not keep IrfanView as my default image viewer in Linux. But I have left IrfanView installed under WINE, as I may yet want to use it under Linux at some point.

WINE tips: Giving each Windows application its own environment

I’m going to tell you about the useful WINEPREFIX environment variable, and, as a bonus, you’ll also find out how to install Office 2007 and IrfanView in WINE, plus how to configure file associations so that double-clicking on a .doc and/or .docx file will launch Word 2007 and open the file.

BACKGROUND

I’ll wager most WINE users have not heard of the WINEPREFIX environment variable and are installing all Windows applications in the ~/.wine/ directory tree. Until a couple of months ago that’s what I was doing too, but these days I install all Windows applications in WINE using this clever WINE feature.

Some WINE users will know that it is possible to use the ‘Add application…’ button on the Applications Settings page (the Applications tab) in the winecfg window to specify per-application libraries (DLLs) and graphics settings. For example, a user could use this feature in order to set an override of riched20 (native) for Office 2007 but not for, say, IrfanView. This WINE feature allows you to ‘ring fence’ applications from each other, avoiding the possibility of incompatible DLLs and graphics settings interfering with the working of another application. However, WINE still keeps directories and files for all the Windows applications in the ~/.wine/ directory tree.

The WINEPREFIX environment variable enables you to go a stage further. By using a WINEPREFIX you can install each Windows application (or a group of applications) in its own, completely separate environment. For example you could install IE7 in ~/.wine-ie7/, IrfanView in ~/.wine-irfanview/, World of Warcraft in ~/.wine-wow/, Word 2007 in ~/.wine-word2007/ and so on. You could even have different versions of the same Windows application installed simultaneously if you wanted. Not only does a WINEPREFIX allow you to keep an application’s DLLs and all settings completely separate from those of other applications, thus avoiding or preventing conflicts, it means that uninstalling a Windows application becomes as simple as:

$ rm -rf ~/.wine-visio5

You no longer need to hope that wine uninstaller supports the application, or that the application’s uninstaller will work if launched directly via WINE.

If winecfg’s Applications Settings allows you to partially isolate an individual application, the use of a WINEPREFIX allows you to put an application into solitary confinement!

HOW TO USE A WINEPREFIX

Let’s look at a couple of examples.

Installing Office 2007 (including SP2) with its own WINEPREFIX:

$ cd
$ export WINEPREFIX=$HOME/.wine-office2007
$ export WINEARCH="win32" # If WINE was built for 64-bit and 32-bit Windows and you have 32-bit Office 2007.
$ winecfg
$ cd .wine-office2007/drive_c/
$ wget http://www.kegel.com/wine/winetricks
$ chmod +x winetricks
$ cp ~/Downloads/X12-30107.exe . # Office 2007 installer from Microsoft.
$ cp ~/Downloads/office2007sp2-kb953195-fullfile-en-us.exe . # Office 2007 SP2.
$ cp ~/Downloads/officelp2007sp2-kb953195-fullfile-en-us.exe . # Office 2007 SP2 language pack.
$ wine X12-30107.exe # Install Office 2007. If you have an Office 2007 installation DVD then use "wine /path/to/setup.exe" instead.
$ winecfg # Set up riched20.dll as per instructions in Wine AppDB for Office 2007 (it must be "Native (Windows)").
$ ./winetricks msxml3 # Install msxml3 as per instructions in Wine AppDB for Office 2007, to stop SP2 crashing.
$ wine office2007sp2-kb953195-fullfile-en-us.exe # Install Office 2007 SP2.
$ wine officelp2007sp2-kb953195-fullfile-en-us.exe # Install Office 2007 SP2 language pack.
$ ./winetricks wsh56js # Install Windows Scripting Host for the thesaurus.
$ ./winetricks allfonts # Install all the TTF fonts.
$ winecfg # Set usp10 to 'native,builtin' for the equation toolbar in Word.
$ ./winetricks fontsmooth-rgb # Install font smoothing.

I have a KDE Kickoff menu entry Applications > Wine > Programs > Microsoft Office > Word containing the following command:

env WINEPREFIX="/home/fitzcarraldo/.wine-office2007" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-office2007/dosdevices/c:/users/fitzcarraldo/Start\ Menu/Programs/Microsoft\ Office/Microsoft\ Office\ Word\ 2007.lnk

The above command might look complicated, but WINE creates it automatically during the installation of Office 2007. WINE also creates similar Kickoff Menu entries for the other Office 2007 applications.

Having installed Office 2007 using a WINEPREFIX, if I wanted to launch e.g. Word from the command line I’d need to enter the following commands:

$ export WINEPREFIX=$HOME/.wine-office2007
$ export WINEARCH="win32"
$ wine $WINEPREFIX/drive_c/Program\ Files/Microsoft\ Office/Office12/WINWORD.EXE

instead of the following if I had not installed Office 2007 using a WINEPREFIX:

$ env WINEARCH="win32" wine $HOME/.wine/drive_c/Program\ Files/Microsoft\ Office/Office12/WINWORD.EXE

Installing IrfanView 4.27 with its own WINEPREFIX:

$ cd
$ export WINEPREFIX=$HOME/.wine-irfanview/
$ export WINEARCH="win32"
$ winecfg
$ cd .wine-irfanview/drive_c/
$ wget http://www.kegel.com/wine/winetricks
$ chmod +x winetricks
$ ./winetricks mfc42
$ cp ~/Downloads/iview427_setup.exe .
$ cp ~/Downloads/irfanview_plugins_427_setup.exe .
$ wine iview427_setup.exe
$ wine irfanview_plugins_427_setup.exe

I have a KDE Kickoff menu entry for IrfanView containing the following command:

env WINEPREFIX="/home/fitzcarraldo/.wine-irfanview" WINEARCH="win32" wine C:\\\\Program\\ Files\\\\IrfanView\\\\i_view32.exe

The above command might look complicated, but WINE creates it automatically during the installation of IrfanView.

By installing Office 2007 and IrfanView this way, I keep the DLLs installed by the IrfanView installer completely separate from the DLLs used by Office 2007.

File associations

If you find that Word opens a blank document (Document1) when you double-click on a .doc (or .docx) file then this is a file association issue. In KDE I simply selected Kickoff > System Settings > File Associations and changed all the associations for .doc and .docx from the following:

env WINEPREFIX="/home/fitzcarraldo/.wine-office2007" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-office2007/dosdevices/c:/users/fitzcarraldo/Start\ Menu/Programs/Microsoft\ Office/Microsoft\ Office\ Word\ 2007.lnk

to the following:

env WINEPREFIX="/home/fitzcarraldo/.wine-office2007" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix %U

A different approach is needed if you want IrfanView to open image files when you double-click on them, and I’ll cover that in my next post.