49 lines
2.0 KiB
Nix
49 lines
2.0 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
cfg = config.modules.battlenet;
|
|
yq = "${pkgs.yq}/bin/yq";
|
|
jq = "${pkgs.jq}/bin/jq";
|
|
in
|
|
{
|
|
config = mkIf cfg.enable {
|
|
# Battle.net is installed manually through Lutris, which creates the game
|
|
# config and wine prefix outside of Home Manager's control. The Lutris
|
|
# installer script writes HardwareAcceleration "false" (software rendering,
|
|
# which breaks Battle.net's CEF UI repainting under XWayland), so patch it
|
|
# and the game env after every rebuild. Re-run the rebuild after installing
|
|
# Battle.net for these tweaks to land.
|
|
home.activation.battlenetClientTweaks = hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
shopt -s nullglob
|
|
for game in "$HOME"/.local/share/lutris/games/battlenet*.yml; do
|
|
prefix=$(${yq} -r '.game.prefix // ""' "$game" 2>/dev/null) || continue
|
|
|
|
for configFile in "$prefix"/drive_c/users/*/AppData/Roaming/Battle.net/Battle.net.config; do
|
|
[ -e "$configFile" ] || continue
|
|
if [ "$(${jq} -r '.Client.HardwareAcceleration // ""' "$configFile" 2>/dev/null)" != "true" ]; then
|
|
${jq} '.Client.HardwareAcceleration = "true"' "$configFile" > "$configFile.tmp" && mv "$configFile.tmp" "$configFile"
|
|
fi
|
|
done
|
|
|
|
# GE-Proton's Wayland driver breaks Battle.net's CEF window sizing and
|
|
# painting, and Xalia misrenders the client, so pin both off.
|
|
if [ "$(${yq} -r '.system.env.PROTON_USE_XALIA // ""' "$game" 2>/dev/null)" != "0" ]; then
|
|
${yq} --in-place --yaml-output '.system.env.PROTON_USE_XALIA = "0"' "$game"
|
|
fi
|
|
if [ "$(${yq} -r '.system.env.WINE_SIMULATE_WRITECOPY // ""' "$game" 2>/dev/null)" != "1" ]; then
|
|
${yq} --in-place --yaml-output '.system.env.WINE_SIMULATE_WRITECOPY = "1"' "$game"
|
|
fi
|
|
if [ -n "$(${yq} -r '.system.env.PROTON_ENABLE_WAYLAND // ""' "$game" 2>/dev/null)" ]; then
|
|
${yq} --in-place --yaml-output 'del(.system.env.PROTON_ENABLE_WAYLAND)' "$game"
|
|
fi
|
|
done
|
|
shopt -u nullglob
|
|
'';
|
|
};
|
|
}
|