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
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 published
bottle for each specific user.
Bottle hooks can be created at three levels:
System-wide hooks apply to all bottles on the system, including non-root
user bottles. Thus they are ideal to adapt the bottles to the configuration
or hardware of the machine. These hooks are located in the
User hooks are the same as system-wide hooks but apply only to one specific
user's bottles. They are run after all the system-wide hooks have been
run. They are located in the
Finally, each bottle can have its own set of hooks. These are especially
suited to configure a published bottle for use by each non-root user. This
is also the only kind of hook which is automatically packaged with the
bottle when it is archived, and is thus guaranteed to run when the bottle is
restored later, even if this is on another computer. These hooks are located
scripts.d directory in the
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
nn are two
decimal digits that dictate the order in which the hooks are run, and
name must not contain any dot or tilde and usually
indicates the hook's purpose.
The hooks are then called as described in the following events:
When a bottle is created
template parameter indicates the name of the
template the bottle is based on, for instance
When a bottle is restored
When a bottle is upgraded to a new CrossOver version
old-bottle-version is the CrossOver version
the bottle was last used with. This can help you gauge how out of date the
bottle was, but note that the hooks are called only after CrossOver has
upgraded the bottle.
When a bottle stub is created
This case happens when a published bottle is used in a non-root account for
the first time. In this case the
variable points to the freshly created bottle stub, while
published-wineprefix points to root's reference
When a bottle stub is updated
This case happens when the administrator has updated the published bottle's
reference copy in
published-wineprefix and the
user's bottle stub must not be updated to match.
In all cases the hooks are called in the Wine context. This means they don't
need to use the
--bottle option and that they can count on
the following environment variables being set:
Contains the absolute path to the directory where CrossOver is installed.
Contains the name of the current bottle.
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
#!/bin/sh rm "$WINEPREFIX/dosdevices/y:" if [ ! -d "$WINEPREFIX/dosdevices/h:" ] then ln -s -f "$HOME" "$WINEPREFIX/dosdevices/h:" fi