Created
July 18, 2021 10:00
-
-
Save kakra/2f1b366f8760ad74667264688e42bbf6 to your computer and use it in GitHub Desktop.
Proton gamemode wrapper script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/user/game.slice.d/99-resources.conf | |
[Unit] | |
Description=Game Slice | |
[Slice] | |
CPUWeight=2000 | |
IOWeight=400 | |
#MemoryLow=16G |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# staging / development stuff not part of Proton | |
#export STAGING_RT_PRIORITY_SERVER=90 | |
#export STAGING_RT_PRIORITY_BASE=50 | |
#export STAGING_SHARED_MEMORY=1 | |
#export STAGING_SHARED_MEMORY=0 | |
#export PBA_DISABLE=1 | |
# seems to be defaults now | |
#export WINEESYNC="${WINEESYNC:-1}" | |
#export WINEFSYNC="${WINEFSYNC:-1}" | |
#export WINEFSYNC_SPINCOUNT=10 | |
#export PROTON_NO_FSYNC=1 | |
#export WINEFSYNC_FUTEX2="${WINEFSYNC_FUTEX2:-1}" | |
# DLSS / Raytracing | |
#export PROTON_HIDE_NVIDIA_GPU=0 | |
#export PROTON_ENABLE_NVAPI=1 | |
#export VKD3D_CONFIG="${VKD3D_CONFIG:+,}dxr" | |
# debugging / logging | |
#export WINEDEBUG=-all | |
#export WINEDEBUG="+all,trace-all" | |
#export WINEDEBUG="+timestamp,+pid,+tid,+seh,+debugstr,+loaddll,+mscoree,+dxgi,+vulkan" | |
#export WINEDEBUG="+timestamp,+pid,+tid,+seh,+debugstr,+loaddll,+mscoree" | |
#export VKD3D_DEBUG=trace | |
# audio | |
#export PULSE_LATENCY_MSEC=60 | |
export SDL_AUDIO_FREQUENCY=48000 | |
export SDL_AUDIO_CHANNELS=6 | |
# graphics | |
#export PROTON_USE_D9VK="${PROTON_USE_D9VK:-1}" | |
#export DXVK_CONFIG_FILE="${HOME}/.config/dxvk.conf" | |
export __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 | |
# memory | |
export PROTON_FORCE_LARGE_ADDRESS_AWARE=1 | |
#export PROTON_HEAP_DELAY_FREE | |
# DLL overrides | |
#export WINEDLLOVERRIDES="overlay=d;winedbg.exe=d${WINEDLLOVERRIDES:+;$WINEDLLOVERRIDES}" | |
# Discord Rich Presence | |
export WINEDLLPATH="/opt/discord-rpc/bin64:/opt/discord-rpc/bin32${WINEDLLPATH:+:$WINEDLLPATH}" | |
export WINEDLLOVERRIDES="discord-rpc=n${WINEDLLOVERRIDES:+;$WINEDLLOVERRIDES}" | |
# Joystick hack, disable by default except when using PROTON_USE_JOYSTICK=1 | |
[ "${PROTON_USE_JOYSTICK}" -eq "1" ] || export SDL_GAMECONTROLLER_IGNORE_DEVICES=0x044F/0xB10A,0x044F/0xB687 | |
# fix sometimes needed for dynamic resolution to properly work | |
#export __GL_SYNC_TO_VBLANK=1 | |
#export PROTON_DUMP_DEBUG_COMMANDS=1 | |
echo "# $*" >>/tmp/gamemode.log | |
export >>/tmp/gamemode.log | |
case "$1" in | |
*/proton) | |
STEAM_PPID=${PPID} | |
( | |
for second in $(seq 1 30); do | |
echo "Waiting for wineserver child of ${STEAM_PPID}... (${second}s)" >>/tmp/gamemode.log | |
sleep 1 | |
wspid=$(pgrep -P${STEAM_PPID} wineserver) | |
[ "${wspid}" -gt 0 ] && { schedtool -n -15 -I ${wspid}; exit; } | |
done | |
) & | |
GAMEMODEAUTO="/usr/\$LIB/libgamemodeauto.so" | |
export LD_PRELOAD="${GAMEMODEAUTO}${LD_PRELOAD:+":${LD_PRELOAD}"}" | |
# Prevent fsync / sync for non-blocking writes | |
EATMYDATA="/usr/\$LIB/libeatmydata.so" | |
export LD_PRELOAD="${EATMYDATA}${LD_PRELOAD:+:$LD_PRELOAD}" | |
;; | |
*/_v2-entry-point) | |
echo "Guessing we are running in bwrap mode" >>/tmp/gamemode.log | |
( | |
for second in $(seq 1 30); do | |
echo "Waiting for wineserver... (${second}s)" >>/tmp/gamemode.log | |
sleep 1 | |
wspid=$(pgrep wineserver) | |
[ "${wspid}" -gt 0 ] && { schedtool -n -15 -I ${wspid}; exit; } | |
done | |
) & | |
esac | |
exec systemd-run --user --same-dir --slice game.slice --scope "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment