Manage Wine Prefixes

# Manage Wine Prefixes

The goal of this tool is to manage Wine prefixes from the command line.

It is a very thin wrapper around Wine commands to make it simple to manage multiple prefixes and usual commands (winetricks, dxvk).

## Installation

You can install it using PyPI:

pip install wine-ctl


Or you can run it in-place since it has very few dependencies (you only need the ansible-roles-ctl script, version.py is only used in the build process).

You need the following dependencies:

• Wine, any version except:
• Python >= 3.6 with the following libraries:
• pyyaml
• jsonschema
• argcomplete >= 1.9.2

On Debian systems you can install them using:

apt install wine64-development wine32-development python3-yaml python3-jsonschema python3-argcomplete


Or you can use WineHQ package.

These are also recommended:

apt install winetricks dxvk-wine64-development dxvk-wine32-development


You can use the stable version of Wine on Debian too, but if wine-development is available then it will be preferred.

## Configuration file

The ~/.config/wine-ctl.yml configuration file is required but very simple. In fact only install_path is needed to know the path of your Wine prefixes.

Necessary binaries are automatically found in the PATH but it is possible to create overrides.

If you have a program library, then you can specify the path (app_lib_path) where your downloaded files are stored. Then if you create prefixes with the same game directory name it will reflect on the listing and suggest installers to run at creation time.

If you wish certain files to be present in your home directory in the Wine prefix (your Windows home), then you can specify the path of files to be copied (home_skel) when the prefix is created.

You may also wish to define specific environment variables to be set when running Wine in a prefix. This can be handy to pass parameters for your driver (RADV_PERFTEST), libraries (SDL_VIDEODRIVER, recommend empty on Wayland at the moment), or tools (DXVK_*).

## Binaries Schemes

In the bin_path_schemes dictionnary in the configuration you can define any number of custom schemes which define where to find specific binaries. It can be useful if you wish to switch between different version of Wine and related tools.

The paths for wine, winedbg, wineboot, winecfg, dxvk-setup and winetricks have to be defined, although the patch for dxvk-setup and winetricks may be set to Null to lookup on the PATH instead of an override.

To select a specific scheme use the --bin-path-scheme command line option (or the shorter -s). You can define a default scheme to use anytime this option is not specified with the default_bin_path_scheme configuration file parameter.

A common configuration for WineHQ packages would be:

bin_path_schemes:
devel:
wine: /opt/wine-devel/bin/wine
wineserver: /opt/wine-devel/bin/wineserver
winedbg: /opt/wine-devel/bin/winedbg
wineboot: /opt/wine-devel/bin/wineboot
winecfg: /opt/wine-devel/bin/winecfg
'dxvk-setup':
winetricks:
staging:
wine: /opt/wine-staging/bin/wine
wineserver: /opt/wine-staging/bin/wineserver
winedbg: /opt/wine-staging/bin/winedbg
wineboot: /opt/wine-staging/bin/wineboot
winecfg: /opt/wine-staging/bin/winecfg
'dxvk-setup':
winetricks:
default_bin_path_scheme: devel


## Program Library

A library is simply a storage layout for your programs:

• one subdirectory per game
• each subdirectory containing installers for the game (setup, patches, mods…)

GoG users using lgogdownloader to download their games will end-up with such a structure but you do not need to use GoG to use this feature, you just need to store your files using this simple layout.

To enable use of the library you just need to specify the app_lib_path in your configuration file.

When creating a new Wine prefix, if you use the same name as the program subdirectory, then wine-ctl will know it is part of your library and several commands will take advantage of this.

## Completion

Command completion is done using argcomplete. It needs to be enabled first to work. The easiest way is to use the activate-global-python-argcomplete3 script as root. Other methods are described on the argcomplete website.

## Firejail Support

(for wine commands only)

You may set the firejail_profile parameter with the name of the Firejail profile to use to enable this feature.

It is recommended that you further restrict all directories that should not be read or written by Wine. The library path, if used, should be set read-only. You may also restrict access to your Wine prefixes using a glob and the needed prefix will be authorized.

If firejail_nonet is set to True (the default), then net access will be restricted except for winetricks.

## GameMode Support

If gamemoderun is found in the path then it will automagically be used to run the program.

If also using Firejail, then you need to add "ignore noroot" in your local overrides (~/.config/firejail/<firejail_profile>.local).

## Usage

Syntax is as follow:

wine-ctl [global options] [subcommand] [subcommand options]


You can use -h/--help option to list all available options at command and subcommand level, as well as all available subcommands.

Follows documentation about the various subcommands.

### List

wine-ctl list


This subcommand displays the list of properly setup prefixes. The L flag indicates it is part of your library.

### create

wine-ctl create <prefix-name>


This subcommand creates a new prefix. You may also specify the -u option if you wish to update an already created prefix.

If you wish to lookup for an installer in your library then use the -l option. The prefix name needs to match the game directory in your library. You can run multiple installers using this command, one at a time, as the prefix will be preserved after the first invocation.

### config

wine-ctl config <prefix-name>


This subcommand is a shortcut for the winecfg command. It is equivalent to wine-ctl run <prefix-name> winecfg.

### run

wine-ctl run <prefix-name>


This subcommand runs a command in the prefix. If not specified then a list of available shortcuts (lnk) will be presented. If --exe is used then available executables are listed instead.

The command can be either a UNIX path (practical to select an installer) or a command which should be available in the prefix already (like usual Wine commands: winecfg, winefile, control, wineconsole…). If you wish to specify command options the you need to quote the command, for e.g.:

wine-ctl run <prefix-name> "reg query 'HKEY_CURRENT_USER\Software\Wine\DllOverrides'"


### dxvk

wine-ctl dxvk <prefix-name>


This subcommand is a wrapper to install or uninstall DXVK in the prefix.

If run without action then it displays the current installation status.

### trick

wine-ctl trick <prefix-name>


This subcommand is a wrapper to run winetricks in the prefix.

### dosbox

wine-ctl dosbox <prefix-name>


This subcommand scans for dosbox games and run them using a locally installed dosbox engine.

Currently only GOG layouts are detected.

This avoid going through Wine as dosbox is available in many distributions. Moreover it may be beneficial to use a more recent version than the one shipped with the game.

The ~/.config/wine-ctl_dosbox.conf configuration file, if present, is used to override specific settings. For example it may be convenient to change the midi/midiconfig parameter to match your sound configuration.

Additionally, mount and imgmount paths are converted to UNIX slash convention on-the-fly using temporary files (leaving the original files untouched).

### scummvm

wine-ctl scummvm <prefix-name>


This subcommand scans for scummvm games and run them using a locally installed scummvm engine.

This avoid going through Wine as scummvm is available in many distributions. Moreover it may be beneficial to use a more recent version than the one shipped with the game.

### library

wine-ctl library


This subcommand displays the list of programs in the library. The I flag indicates it is installed (in a Wine prefix of the same name). The w and l flags indicate if an installer is available for Windows or GNU/Linux, respectively.

### shutdown

wine-ctl shutdown <prefix-name>


This subcommand shuts down the prefix: all processes in the prefix are terminated. It waits for the shutdown to be completed.

### debug

wine-ctl debug <prefix-name>


This subcommand displays the list of processes in the prefix and run winedbg in order to collect debugging information about a faulty program.

More information about the procedure is available on the Wine wiki and in the winedbg manpage.

## Project details

Uploaded source
Uploaded py3