Thursday, July 2, 2009

A visit to the Wine Cellar

WINE (Wine is not an emulator), is a nifty tool that you can use to run Windows applications on Linux. WINE is currently an incomplete implementation of the Windows API, and as such, not everything will run on it. This article will explore some of the things that WINE is capable of.

For starters, to install wine, simply get it from your distribution's repository (like sudo apt-get install wine), or go to winehq.org and get more info on how to install it. You could also download the sources and compile it yourself, though that is not the simplest path here.

WINE Commandments
Well, more like guidelines, really...

1. Thou Shalt use the command line: You can start a windows app by double clicking it (or right clicking it and selecting "Open with WINE", but this is not recommended. The correct way to start applications using WINE is to use the command line. Type "wine" in the terminal to get usage details. For example, "wine test.exe" will launch the file called test.exe present in the current directory.

2. winecfg shalt light your path: To set various wine parameters, type "winecfg". This will bring up a control panel that will be discussed in detail later.

3. WINE shalt hide from you in the shadows: WINE creates its files in a hidden directory in your home folder. "cd ~/.wine" will take you there. Here, you will see a "drive_c" directory. This is your virtual C Drive. It contains a Windows folder, a Program Files folder etc... The .wine directory also contains a regedit.exe, a notepad.exe and some other small utilities. Typing "regedit" in the terminal will take you to your "new" registry, in case you want to do something there.

4. Seek in system32, and you shall find: When you (try to) run a windows program using WINE, one of 3 things will happen: It will run, or it will complain about missing dlls, or it will segfault and throw up. If it runs, fine. If it throws up, there is no easy answer, but its mostly that the program won't run. If it complains about DLLs, which happens often, all you need to do, is copy the correct windows DLL file to your "new" system32 directory... which is located here: "~/.wine/drive_c/windows/system32". Where can you get these DLL files? Online, or from your licensed copy of Windows, which you have installed on a different partition on this machine. Most often, if you try to play games, you will have to copy DirectX dll files from your original Windows\system32. Note that this is the reason I ask you to use the command line. If you use WINE from the GUI, you cannot the error messages, and wont know why a program is not working.

Installing apps on WINE

You could install applications on WINE using the regular Setup programs you use in Windows, or you could try to run these programs directly from where you had installed them on windows (without reinstalling in linux). The second option is less recommended, but works often, specially with games.
WINE also adds a menu item in your default gnome / kde menu. So you can also 'uninstall' programs from here. You could also simply go to the ".wine/drive_c/Program Files" directory and delete the application from there.

Mounting images in WINE
If you are using backed up CD-Images to run your games on windows, doing the same thing on linux may be a bit harder. Firstly, some (many) copy protection systems like securom and Tages may not work on linux.

But anyway, you probably have a CD image (ISO / cue / bin / mdf ) file that you want to mount. If you have an ISO for example, make a directory (say, virtualdrive) in your home folder and simply mount the image in that directory:
sudo mount image.iso ~/virtualdrive -t iso9660 -oloop

Now, the image is mounted, but your game does not know where to find it. So type 'winecfg' into the terminal, to bring up the wine configuration tool. Here, go to the "Devices" tab, and click on "Add" to add a new device. Type the path to your device (~/virtualdrive for example) under the field "Device Mapping". winecfg would have automatically assigned a drive letter to this drive. You can also click on "Advanced" and select "CD-ROM" as the device Type. Now, your game can read the new virtual drive as though it was a regular CD drive.

Note that its not generally possible (AFAIK) to mount mdf files in linux. You can download and install the tool IAT that converts from various formats to ISO format.

WINE Extras

Sometimes, a few programs will complain that a certain library is missing, or that HTML rendering is disabled, etc... Here are a few solutions to such problems:

1. Microsoft TrueType Fonts: Sometimes, while using WINE, you will have problems with fonts in the application you are running. This is because you do not have the microsoft fonts installed on linux. Here is how you should do it:

Ubuntu (man, these deb guys are crazy, they have every damn package in their repository):
apt-cache search msttcorefonts

Other distros (slightly longer method): Visit corefonts.sourceforge.net

2. HTML Renderer on WINE: Wine Gecko is a HTML rendering engine that you can use to see webpages in applications that you run on wine. For example, CounterStrike displays a html page on loading a new map. To install Gecko, simply visit the Official Gecko Page and follow the instructions given there.

3. VB Runtimes: You may want to install visual basic runtimes from here. In case this microsoft link expires, just google for vbrun60sp6.exe

4. DirectX: Similar story here, just go to the microsoft webpage, get their latest Direct X installer, and run it. The application you are trying to install may also come with a DirectX installer.

I can't really think of anything more to write right now, but if I may add a new post sometime later, to discuss some specific wine feature...

Wednesday, July 1, 2009

Beep Beep!!

The PC speaker is a relic from the medieval times when people were awed by the sound effects of Dangerous Dave... But strangely enough, it is used heavily by most linux distros. This is most noticeable if you do text editing in the terminal, or inside gnome(sometimes kde) default apps like gedit...

If you are one of those people who does not appreciate the fact that their machine can do a very good Road Runner impression, here is how you can fix things:

Firstly, if you are facing this problem only in gnome-terminal, you can turn off system beep from the terminal options (Edit->Profile Preferences, uncheck "Terminal Bell")

If you want a slightly geekier (and more effective) solution, you can disable the PC speaker in this way:

sudo modprobe -r pcspkr

This will disable the PC Speaker for the current session. If you want a more permanent solution, you can blacklist the PC Speaker by editing the "/etc/modprobe.d/blacklist" file.

sudo gedit /etc/modprobe.d/blacklist

Then add this line at the end of the file:

blacklist pcspkr

Save the file, and next time you start your machine, and there should be no more of that infernal beeping.

modprobe is a utility that can load and unload linux modules. To learn more about it visit the Wiki page