Skip to content

Instantly share code, notes, and snippets.

@kreeger
Last active December 19, 2023 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kreeger/620b2c4c303199cd995eb8cde0202552 to your computer and use it in GitHub Desktop.
Save kreeger/620b2c4c303199cd995eb8cde0202552 to your computer and use it in GitHub Desktop.
Finds latest version of Steam Linux Runtime (sniper) and uses its library path to help run RetroArch, installed via Steam.

Running Steam-installed RetroArch on a Steam Deck

Script overview

This script lets you run Steam-installed RetroArch with command line arguments on a Linux-based system and lets you create separate Steam entries for each ROM, with a command like so (something like this should be in the "target" field):

"/path/to/where/Steam/installs/RetroArch/retroarch.sh" \
    -L /path/to/where/Steam/installs/RetroArch/cores/some_core_libretro.so \
    "/path/to/where/your/roms/are/Some ROM.7z"

Make sure to customize paths accordingly, and set the "start in" directory to be the directory where RetroArch lives (in this example, /path/to/where/Steam/installs/RetroArch).

Using this with Steam ROM Manager

This is all best done en-masse with Steam ROM Manager, and a config for each platform you're emulating.

  • Set your environment variable settings for a better time:
    • steamdirglobal is /home/deck/.steam/steam on a Steam Deck
    • romsdirglobal is /run/media/mmcblk0p1/Emulation/roms if they're installed on an SD card
    • retroarchpath is /home/deck/.local/share/Steam/steamapps/common/RetroArch/retroarch.sh, which is where Steam installs RetroArch by default, and then it's the path to this script which you should download and place next to where retroarch lives in there (in RetroArch/)
    • Cores directory is /home/deck/.local/share/Steam/steamapps/common/RetroArch/cores
  • Setup a parser for each System/Core combination
    • Use a glob parser, set your configuration title to be the system and core you're using
    • Steam directory should be ${steamdirglobal}
    • Steam category is what you want the grouping to be called in Steam; this needs to be inside a set of #{...} brackets, like ${Emulation - NES}
    • ROMs directory is something like ${romsdirglobal}/nes
    • Executable is ${retroarchpath}, and "Append arguments to executable" is enabled
    • Command line arguments is this funky glob: -L ${os:win|cores|${os:mac|${racores}|${os:linux|${racores}}}}${/}some_core_libretro.${os:win|dll|${os:mac|dylib|${os:linux|so}}} "${filePath}" where some_core_libretro.so is an actual core in your Cores directory
    • Executable modifier is "${exePath}"
    • User's glob is something like ${title}@(.7z|.7Z|.fds|.FDS|.nes|.NES|.unif|.UNIF|.unf|.UNF|.zip|.ZIP) where you do your best to try and match every file extension you'd expect to have for ROMs for that particular core; this example is for NES
    • There are tons of other options to tweak for doing image searching, but I make sure to have ${fuzzyTitle} set as Title modifier, and have all 3 "Fuzzy matching" options enabled.
  • Once you have this all configured, test the parser to make sure it picks up all the system's ROMs, and then go to Preview, make sure Steam is closed, and hit Parse, pick the images you want, and then hit Save to Steam.
  • I recommend only running one parser at a time (disable the rest, only enable one, and do a Preview -> Save run). Downloading a gajillion images from steamgriddb is bad for both you and that website.
#!/bin/sh
# Run Steam-installed RetroArch with command line arguments on a Linux-based system.
# Update the linker library path to look for the Steam Linux Runtime files, and use the latest version,
# no matter which directory that's in (matches[-1] takes the last match)
script_full_path=$(dirname "$0")
snipers="/home/deck/.local/share/Steam/steamapps/common/SteamLinuxRuntime_sniper/sniper_platform_*"
matches=($snipers)
latest_sniper=${matches[-1]}/files/lib/x86_64-linux-gnu
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$latest_sniper
# Now that that's exported, run `retroarch` in the same directory as this script, and forward any
# command line arguments passed to _us_ to _it_
$script_full_path/retroarch "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment