LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   Prefix-aware menuing system to launch WINE games (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/prefix-aware-menuing-system-to-launch-wine-games-4175661989/)

dugan 10-04-2019 04:20 AM

Prefix-aware menuing system to launch WINE games
 
I've found that I tend to maintain WINE prefixes from the command line (winecfg, winetricks, DXVK/mf-cab/d9vk installers, environment variables, etc), and all I use Lutris for, is adding the games and their prefixes to its menu after I've already set them up.

No, I don't use the game installation scripts provided by Lutris' community. Is my way the best way? Maybe not, but it's what I'm used to.

Anyway, if that's all I'm doing with Lutris then I don't need it. To replace it, I just came up with a menuing system to launch these games after you've set up their prefixes.

The data for the menu is a JSON file, at ~/.config/wine_games.json. Here's an example with one entry:

Code:

{
  "GOG Galaxy": {
    "exe": "/home/dugan/.local/share/wineprefixes/galaxy/drive_c/Program Files (x86)/GOG Galaxy/GalaxyClient.exe",
    "prefix": "/home/dugan/.local/share/wineprefixes/galaxy"
  }
}

I assume it's self-explanatory and readable. "GOG Galaxy" is what appears in the menu. We also have the path to the prefix and the path to the executable.

Note that the paths do not, and cannot, contain tildes or variables. This is actually a technical limitation of the menuing script:

Code:

#!/usr/bin/env bash

set -e

GAME=$(jq -r 'keys[]' ~/.config/wine_games.json | dmenu)

if [[ "$GAME" == "" ]]; then
  exit
fi

EXE="$(jq -r ".\"$GAME"\".\"exe\" ~/.config/wine_games.json)"
PREFIX="$(jq -r ".\"$GAME"\".\"prefix\" ~/.config/wine_games.json)"

if [ ! -d "$PREFIX" ]; then
  echo Prefix not found
  exit 1
fi

if [ ! -f "$EXE" ]; then
  echo Executable not found
  exit 1
fi

WINEDEBUG="-all" WINEPREFIX="$PREFIX" wine start /unix "$EXE"

Note the use of dmenu (feel free to replace it with smenu, rofi, or even FZF) and jq. Note also the use of "wine start /unix", which properly sets the Windows program's working directory.

You just execute the script, select the game from the menu, and launch it.

This is actually my third project to work with WINE prefixes, after wine_env and Wine Bottler, so I do have some experience with this.

dugan 10-04-2019 07:31 AM

As above, I have a prefix for running GOG Galaxy. All I did in it was "winetricks corefonts", because Galaxy needs it, and I'm too proud to install those fonts system-wide.

I used GOG Galaxy to install Blasphemous. I also expect GOG Galaxy to keep it updated.

I set up a separate prefix with DXVK and Media Foundation, because that's what I need to run Blasphemous.

Note that Proton similarly decouples the WINE prefixes from the game installations, and it also keeps the two in separate directory trees.

Now ~/.config/wine_games.json looks like this:
Code:

{
  "GOG Galaxy": {
    "exe": "/home/dugan/.local/share/wineprefixes/galaxy/drive_c/Program Files (x86)/GOG Galaxy/GalaxyClient.exe",
    "prefix": "/home/dugan/.local/share/wineprefixes/galaxy"
  },
  "Blasphemous": {
    "exe": "/home/dugan/.local/share/wineprefixes/galaxy/drive_c/Program Files (x86)/GOG Galaxy/Games/Blasphemous/blasphemous.exe",
    "prefix": "/home/dugan/.local/share/wineprefixes/dxvk_mf"
  }
}

And my menu has two entries.


All times are GMT -5. The time now is 12:04 PM.