Modding NieR Replicant on Linux, and the Proton that had no Wayland
I picked up NieR Replicant (the 2021 remaster) last week, and I play these games for the story and to wander around, not for the grind or the difficulty. So before getting far in, I asked the agent to set up some cheats. On Windows I’d have reached for WeMod or my lifetime CheatHappens membership. On Arch, with the game running under Proton, it was a bit less obvious what would work.
The first answer was “not those”. WeMod’s app runs badly under Wine. CheatHappens is clear that its standalone trainers don’t work on Linux at all, only the ones built into Aurora, and running Aurora on Linux means their paid Steam Deck tool, which only promises the Steam Deck. I had found a mod on Nexus Mods that looked promising, so I asked whether that one would do. The agent couldn’t tell: Nexus answers automated page reads with a 403. Its API is a different matter, so I made an API key for my account and put it in the homenet secrets folder. With that, the agent could read the mod’s description and file list, and, since I have Premium, download files directly. The first download failed with another 403, this time from their download server, which turned out to refuse Python’s default User-Agent. A custom one fixed it.
The mod is the “Nier Replicant Mod Menu” by ifaifa: an in-game window with invincibility, stat and inventory editing, a map you can teleport around, noclip and a speed control. It’s open source, from January this year, and it runs on Lunar Tear, a mod loader from the same author (which also unlocks the frame rate and keeps automatic save backups, both nice to have). Lunar Tear works by posing as one of the game’s DLLs. The game imports dinput8.dll, so that’s the name it got, plus a launch option (WINEDLLOVERRIDES="dinput8=n,b") so Proton loads the copy in the game folder instead of its own. The agent backed up my saves first, then promptly installed the zip archive itself as dinput8.dll, noticed from the file size that it was the wrong thing, and replaced it with the DLL from inside. The settings file it then had to edit had Windows line endings, so the first sed changed nothing and diff said so. Two small slips, both caught by checking the result instead of trusting the command, which is the habit I want it to have.
It worked on the first launch. The menu, though, opened behind the game. NieR runs borderless fullscreen on my wide monitor, and the menu is a second window of the same Windows process, so Hyprland sees the same steam_app_1113560 class on both, and workbench’s rule that sends games to the main monitor sent the menu there too. I’d rather have it on the portrait monitor next to it. A rule in my machine’s host file couldn’t do that, because the host file loads before workbench’s own rules and in Hyprland the later rule wins. So workbench grew a small hook, HOST_LATE_RULES: a function a host file can define that runs after everything else. Mine sends any window titled LTConsole with a steam_app_* class to the portrait monitor, floating and centered.
That’s where the real trouble started. With the menu on the other monitor, the game stopped responding to keyboard and controller (the mouse still moved, sort of, with a comically large pointer). The agent’s first theory was that the menu had stolen focus when it opened, and it said so with more confidence than it had earned. So it wrote a small recorder for Hyprland’s event socket and asked me to reproduce it while it logged every focus change. The log disproved its theory: the menu took focus for an instant and Hyprland gave it straight back. Focus follows the mouse on my desktop, so it was bouncing between the game and the menu as I moved, which was expected. The run that broke was different in one way. On the way to the menu, the pointer had crossed Firefox on the portrait monitor, and once focus left the game’s windows for a non-game app, the game never took input again, no matter how it got focus back. A click sometimes revived it, until the next trip out.
The game was going through XWayland, so the obvious move was Proton’s native Wayland mode, which I already had on for Cyberpunk: PROTON_ENABLE_WAYLAND=1. It changed nothing. The agent checked the running game’s environment, and the variable was there. Then it read Proton’s own launch script, which never mentions Wayland, and listed the display drivers it ships: winex11.so, and that’s it. Proton Experimental 11 has no Wayland driver at all. Which also means Cyberpunk has been ignoring that launch option the whole time. (It runs fine, so I’m not sure what I thought it was doing.)
It offered a Wine registry setting for this exact focus problem, but that felt like a workaround to me, and I’d rather things move to Wayland anyway. I’ve had good results with GE-Proton before, and it was already installed from the AUR. It ships Wine’s Wayland driver and does read PROTON_ENABLE_WAYLAND. The agent backed up my saves again and switched the game over. Input now survives a trip to Firefox and back, and the giant pointer is gone, since that was XWayland’s doing too.
Native Wayland brought one new quirk. NieR is set to borderless fullscreen in its own options, and under Wayland it insists on it: when I tried to drag it out of fullscreen onto a new workspace, it re-asserted fullscreen every time Hyprland dropped it. The recorder logged about 38,000 fullscreen toggles in a few seconds, peaking around 6,700 a second, with the window bouncing between monitors about forty times as I dragged. If I want it in a window, that has to be set to Windowed in the game’s own options. What it left behind was stranger: the portrait monitor’s workspace kept believing it had a fullscreen window when it didn’t, which hid Firefox and the menu entirely, and later the same thing swallowed a kitty window on the main monitor. Leaving the workspace and coming back cleared it. Some of that is probably a Hyprland bug, but I’ve also noticed workbench won’t open a new workspace on one monitor while the other one’s is empty, which is likely ours. That’s written up for its own session.
The useful leftovers are two tools in the desktom repo. tools/steam-launch.py shows and sets a game’s launch options and its Proton build. Steam rewrites those files from memory when it exits, so the tool closes Steam first (refusing if a game is running), backs up the file, writes the change, reads it back and starts Steam again in my session. The agent tested that by adding and removing a harmless option and checking Steam kept it through its own rewrite, and from now on it doesn’t have to wait for me to type into a dialog box. tools/nexus.py uses my key to look up mods, list their files and download them into a fresh folder, with a checksum and a listing but never unpacked. Nothing goes into a game folder until someone has read it.
So: a mod menu, a mod loader, a new Proton, a Hyprland hook and two tools, for a game I wanted to play more casually. That seems about right.