Customizing bottles using bottle hooks

Bottle hooks are a mechanism that lets you automatically customize the bottles created by CrossOver. Because it relies on scripts, it is very flexible. For instance it can modify drive letter assignments but also registry settings, the contents of the c: drive, etc. This mechanism is especially useful when you want to customize a bottle which you distribute to a range of machines, or to customize a managed bottle for each specific user.

Bottle hooks can be created at three levels:

Each hook is an executable file, usually a shell script, and must be placed in one of the above hook directories. The name of the hook must be of the form nn.name, where nn are two decimal digits that dictate the order in which the hooks are run, and name must not contain any dot or tilde usually indicates the hook's purpose.

The hooks are then called as described in the following events:

In all cases the hooks are called in the Wine context. This means that they can count on the following environment variables being set:

CX_ROOT

Contains the absolute path to the directory where CrossOver is installed.

CX_BOTTLE

Contains the name of the current bottle.

WINEPREFIX

Contains the absolute path to the bottle directory.

Bottle hooks can also use the wine script to call Winelib or Windows applications to modify registry settings or other aspects of the bottle.

Here is an example of a bottle hook that modifies the drive letter assignments so that there is no Y: drive, and the H: drive points to the user's $HOME directory.

#!/bin/sh
rm "$WINEPREFIX/dosdevices/y:"
if [ ! -d "$WINEPREFIX/dosdevices/h:" ]
then
    ln -s -f "$HOME" "$WINEPREFIX/dosdevices/h:"
fi