Script to extract rom from archive

Hey all :slight_smile: loving Lutris so far, slowly setting it up on bullseye. I want to implement a script to extract rom and bin/cue files from archives, as all of my emulated games are stored in zip or 7z archives. Saves me a couple TBs of space. I had a look around and couldn’t find any documentation that might assist. I’m a linux noob, but I’m sure I can figure out the archive extraction part with some time and grief, but not sure how to point to the actual file in question. Any suggestions are welcome.

1 Like

Well I usually use this to unzip a whole bunch of archives in one folder and auto detect the folder name:

for i in *.zip; do unzip "$i" -d "${i%%.zip}"; done\

For 7zip the command is as follows:

for i in *.7z; do 7z x -o"`basename \"$i\" .7z`" "$i"; done

Install p7zip to unzip *.7z files on Fedora

sudo dnf install p7zip p7zip-plugins

Install p7zip to unzip *.7z files on Debian and Ubuntu

sudo apt-get install p7zip-full

This command will give you more information on how to use the commands:

unzip --help
7z --help

If you need a more specific example for your situation, let us know.

1 Like

Hey tfk, thanks for the help :slight_smile: Do I need to modify those two commands (the 7z and zip extraction commands) to get them to work as a pre-launch script? I copied those commands into .txt files and used those as the pre-launch scripts and checked the ‘wait for pre-lauch script completion’ box. But the emulator is telling it’s the wrong format and there’s no extracted ROM in the directory of the zip/7z files, so I’m doing something wrong :sweat_smile:

EDIT: and both commands work fine in cli…

Add them to a bash script.

#!/bin/bash

Code here

Save as something.sh and reference it in the appropriate field.

1 Like

Ah I see. Once again script runs fine in terminal, but won’t load up via pre-lauch script option in Lutris, so I’m still doing something wrong… :woman_shrugging: On the plus side, I think I’ve now officially overcome the Dunning-Kruger effect now, as I can see I’ve got a lot of learning to do :woman_facepalming: Just downloaded a course on bash scripting which should at least help after I’ve gotten through some of it.

Maybe it needs the script to be executable.

chmod u+x ./file.sh

This gives execute permissions for the current user to the script in the current directory.

Bash scripting is a very powerful tool. Highly recommended. :+1:

1 Like

Yeah I had no idea bash scripting was even a thing :sweat_smile: I just thought all this stuff had to be done with python/etc :joy: very cool

Hmm… still seems like it’s not running… I’d already made it executable via nautilus gui, but updated everyone to full rwx in case, and still not running… :face_with_raised_eyebrow: wonder what it is. Maybe I’ll post the code here in case I’m making an uber noob error :sweat_smile: but still don’t see how it could be the script as it runs fine when i manually run it…

#!/bin/bash
for i in *.7z; do 7z x -o"`basename \"$i\" .7z`" "$i"; done

No need to update the permissions for everyone. If the script works from the terminal then it should work elsewhere too.

I would check whether the script is executed in the same location as the 7z archives. It expects the archives to be in the same location as the script.

You could test this by specifying the complete path in the script. You can also run the emulator from the terminal so you can see any errors or messages which are generated.

The script with the full path would be as follows:

#!/bin/bash
cd /home/username/directory-with-archives/
for i in *.7z; do 7z x -o"`basename \"$i\" .7z`" "$i"; done

You could also use variables to store the location where the archives are and where the extracted files need to go. But first try to see whether you can run the script from the emulator.

It is always handy to post the script in question. And maybe a screenshot of the field where the script is entered.

1 Like

Ah good idea! I was certain you’d found the solution, but when I tested it it still doesn’t run! :face_with_raised_eyebrow: I moved the script to the same directory as the archives, manually ran it and it worked. Then updated the script to include the cd command, munaually ran it and it worked. But neither work through lutris.

I’m not sure what you mean by running the emulator from the terminal. You mean CLI mode in the emulator options in lutris? If so no error messages, just same old wrong rom format dialogue. Oh not sure if the following information has any relevance, but I’m using yuzu (not a custom runner executable) and it does successfully run non-archived roms.

EDIT: I am currently using the script via the pre-launch option. Is that the appropriate option?

Ah yuzu. If I can find a rom I can test this.

By running from terminal I meant running lutris from the terminal. I said emulator. Sorry about that.

Running lutris from the terminal can be done via this command:

lutris -d

This way you can probably see what the script is doing.

You could also add an echo call to write out some text. This way you know that the script is executing.

#!/bin/bash
echo "UNARCHIVING ROM"
cd /home/username/directory-with-archives/
for i in *.7z; do 7z x -o"`basename \"$i\" .7z`" "$i"; done

If the script isn’t called, we need to investigate why. Maybe it’s a timing issue.

1 Like

Oh cool, I got ya now :slightly_smiling_face: Okay now we’re getting somewhere. It looks like there’s something going wrong reading the path because it includes a space. I’m surrounding the path with " marks, so it should work right?

#!/bin/bash
echo "UNARCHIVING ROM"
cd "/media/storage/extract test"
for i in *.7z; do 7z x -o"`basename \"$i\" .7z`" "$i"; done
2021-10-29 21:32:50,770: Starting Lutris 0.5.9.1
2021-10-29 21:32:52,174: Failed to read content length on response from https://api.github.com/repos/lutris/dxvk/releases
2021-10-29 21:32:53,221: Startup complete
INFO     2021-10-29 21:32:53,226 [startup.check_driver:53]:Using NVIDIA drivers 460.91.03 for x86_64
INFO     2021-10-29 21:32:53,226 [startup.check_driver:57]:GPU: GeForce RTX 2070 Super
INFO     2021-10-29 21:32:53,227 [startup.check_driver:73]:GPU: 10DE:1E91 1028:099D (nvidia drivers)
INFO     2021-10-29 21:32:53,227 [startup.check_driver:73]:GPU: 8086:9BC5 1028:099B (i915 drivers)
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

DEBUG    2021-10-29 21:32:54,126 [lutriswindow.update_store:451]:Showing 5 games
DEBUG    2021-10-29 21:33:02,285 [yuzu._update_key:75]:No prod_keys file was set.
DEBUG    2021-10-29 21:33:02,285 [yuzu._update_key:75]:No title_keys file was set.
DEBUG    2021-10-29 21:33:02,299 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
WARNING  2021-10-29 21:33:02,402 [game.start_prelaunch_command:361]:Command /media/storage/extract not found
DEBUG    2021-10-29 21:33:04,404 [command.start:139]:DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1="1"
DEBUG    2021-10-29 21:33:04,404 [command.start:139]:SDL_VIDEO_FULLSCREEN_DISPLAY="off"
DEBUG    2021-10-29 21:33:04,408 [command.start:139]:DRI_PRIME="1"
DEBUG    2021-10-29 21:33:04,408 [command.start:139]:LD_LIBRARY_PATH="/lib/x86_64-linux-gnu:/lib/i386-linux-gnu:/lib32:/lib:/lib/i386-linux-gnu/i686/sse2:/lib/i386-linux-gnu/sse2:/usr/lib/x86_64-linux-gnu/libfakeroot:/lib64:/lib64:/usr/lib:/usr/lib64:/usr/lib32:/usr/lib64:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/laptop/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/lib:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
DEBUG    2021-10-29 21:33:04,408 [command.start:139]:game_name="Test 7zip Space"
DEBUG    2021-10-29 21:33:04,409 [command.start:139]:PYTHONPATH="/usr/lib/lutris:/usr/games:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages"
DEBUG    2021-10-29 21:33:04,409 [command.start:139]:LUTRIS_GAME_UUID="4448b6cb-b159-407c-8ab4-3786b24880b2"
Started initial process 25816 from /home/laptop/.local/share/lutris/runners/yuzu/yuzu /media/storage/extract test/Moving Out [0100C4C00E73E000][v0].7z
Start monitoring process.
QPixmap::scaled: Pixmap is a null pixmap

When I use a path without spaces and adjust the path in the script to match I get this instead. Looks good now, regarding extraction, but then proceeds to try and open the 7zip.

2021-10-29 21:55:50,435: Starting Lutris 0.5.9.1
2021-10-29 21:55:51,843: Failed to read content length on response from https://api.github.com/repos/lutris/dxvk/releases
2021-10-29 21:55:52,219: Failed to read content length on response from https://api.github.com/repos/lutris/dxvk-nvapi/releases
2021-10-29 21:55:52,558: Failed to read content length on response from https://api.github.com/repos/lutris/vkd3d/releases
2021-10-29 21:55:52,874: Startup complete
INFO     2021-10-29 21:55:52,880 [startup.check_driver:53]:Using NVIDIA drivers 460.91.03 for x86_64
INFO     2021-10-29 21:55:52,881 [startup.check_driver:57]:GPU: GeForce RTX 2070 Super
INFO     2021-10-29 21:55:52,881 [startup.check_driver:73]:GPU: 10DE:1E91 1028:099D (nvidia drivers)
INFO     2021-10-29 21:55:52,882 [startup.check_driver:73]:GPU: 8086:9BC5 1028:099B (i915 drivers)
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

DEBUG    2021-10-29 21:55:53,801 [lutriswindow.update_store:451]:Showing 5 games
DEBUG    2021-10-29 21:56:02,298 [yuzu._update_key:75]:No prod_keys file was set.
DEBUG    2021-10-29 21:56:02,298 [yuzu._update_key:75]:No title_keys file was set.
DEBUG    2021-10-29 21:56:02,322 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-10-29 21:56:02,426 [command.start:139]:DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1="1"
DEBUG    2021-10-29 21:56:02,426 [command.start:139]:SDL_VIDEO_FULLSCREEN_DISPLAY="off"
DEBUG    2021-10-29 21:56:02,426 [command.start:139]:DRI_PRIME="1"
DEBUG    2021-10-29 21:56:02,426 [command.start:139]:LD_LIBRARY_PATH="/lib/x86_64-linux-gnu:/lib/i386-linux-gnu:/lib32:/lib:/lib/i386-linux-gnu/i686/sse2:/lib/i386-linux-gnu/sse2:/usr/lib/x86_64-linux-gnu/libfakeroot:/lib64:/lib64:/usr/lib:/usr/lib64:/usr/lib32:/usr/lib64:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/laptop/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/lib:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
DEBUG    2021-10-29 21:56:02,426 [command.start:139]:game_name="Test 7zip"
DEBUG    2021-10-29 21:56:02,427 [command.start:139]:PYTHONPATH="/usr/lib/lutris:/usr/games:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages"
DEBUG    2021-10-29 21:56:02,427 [command.start:139]:LUTRIS_GAME_UUID="75cb2629-7854-4ebc-8141-03c90966f282"
INFO     2021-10-29 21:56:02,430 [game.start_prelaunch_command:370]:Running /media/storage/extract_test/extract_7zip_script.sh in the background
Started initial process 26740 from /media/storage/extract_test/extract_7zip_script.sh
Start monitoring process.
UNARCHIVING ROM

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_AU.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz (A0655),ASM,AES-NI)

Scanning the drive for archives:
1 file, 580038901 bytes (554 MiB)

Extracting archive: Moving Out [0100C4C00E73E000][v0].7z
--
Path = Moving Out [0100C4C00E73E000][v0].7z
Type = 7z
Physical Size = 580038901
Headers Size = 178
Method = LZMA2:14
Solid = -
Blocks = 1

Everything is Ok

Size:       580084672
Compressed: 580038901
Monitored process exited.
Initial process has exited (return code: 0)
All processes have quit
Exit with return code 0
DEBUG    2021-10-29 21:56:03,284 [command.on_stop:193]:Process 26738 has terminated with code 0
DEBUG    2021-10-29 21:56:04,432 [command.start:139]:DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1="1"
DEBUG    2021-10-29 21:56:04,432 [command.start:139]:SDL_VIDEO_FULLSCREEN_DISPLAY="off"
DEBUG    2021-10-29 21:56:04,432 [command.start:139]:DRI_PRIME="1"
DEBUG    2021-10-29 21:56:04,432 [command.start:139]:LD_LIBRARY_PATH="/lib/x86_64-linux-gnu:/lib/i386-linux-gnu:/lib32:/lib:/lib/i386-linux-gnu/i686/sse2:/lib/i386-linux-gnu/sse2:/usr/lib/x86_64-linux-gnu/libfakeroot:/lib64:/lib64:/usr/lib:/usr/lib64:/usr/lib32:/usr/lib64:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/laptop/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/lib:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
DEBUG    2021-10-29 21:56:04,432 [command.start:139]:game_name="Test 7zip"
DEBUG    2021-10-29 21:56:04,432 [command.start:139]:PYTHONPATH="/usr/lib/lutris:/usr/games:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages"
DEBUG    2021-10-29 21:56:04,432 [command.start:139]:LUTRIS_GAME_UUID="b1e8f18f-6212-47d1-979b-a2f3fb72eea7"
Started initial process 26749 from /usr/bin/xterm -e /home/laptop/.cache/lutris/run_in_term.sh
Start monitoring process.

Yes spaces need to be escaped. Quotes work but adding a backslash before the spaces will work too.

a\ file\ with\ spaces

The extraction seems to work. If the 7zip is opened, is this file referenced by the emulator? I can’t see this from here. But generally the emulator needs a reference to the rom which was in the 7zip file.

1 Like

Hmm… well I was using quotes in the script that produced that first log which shows that the path got cut off before the first space. So there’s something wrong there. Is that lutris or something else?

Not at PC at the moment, but will see if I can catch a file reference later :blush:

Alright, this is the log for booting up lutris, running the game, script runs, Yuzu opens up with ‘wrong format’ error dialogue, and then I closed Yuzu… can’t see the ROM filename and/or path referenced… :face_with_raised_eyebrow:
And I think, unless I’m misunderstanding something, that this is only the 2nd problem. The first is the strange issue with the script not working with spaces in the path name. I reproduced that same issue with trying \ slashes instead " marks. But maybe that’s something not related to lutris…?

2021-10-30 19:27:07,647: Starting Lutris 0.5.9.1
2021-10-30 19:27:09,108: Failed to read content length on response from https://api.github.com/repos/lutris/dxvk/releases
2021-10-30 19:27:10,114: Failed to read content length on response from https://api.github.com/repos/lutris/d3d_extras/releases
2021-10-30 19:27:10,115: Startup complete
INFO     2021-10-30 19:27:10,115 [startup.check_driver:53]:Using NVIDIA drivers 460.91.03 for x86_64
INFO     2021-10-30 19:27:10,115 [startup.check_driver:57]:GPU: GeForce RTX 2070 Super
INFO     2021-10-30 19:27:10,115 [startup.check_driver:73]:GPU: 10DE:1E91 1028:099D (nvidia drivers)
INFO     2021-10-30 19:27:10,115 [startup.check_driver:73]:GPU: 8086:9BC5 1028:099B (i915 drivers)
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

DEBUG    2021-10-30 19:27:11,099 [lutriswindow.update_store:451]:Showing 5 games
DEBUG    2021-10-30 19:27:17,996 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-10-30 19:27:18,270 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-10-30 19:27:18,515 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-10-30 19:27:39,871 [yuzu._update_key:75]:No prod_keys file was set.
DEBUG    2021-10-30 19:27:39,871 [yuzu._update_key:75]:No title_keys file was set.
DEBUG    2021-10-30 19:27:39,891 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-10-30 19:27:40,148 [command.start:139]:DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1="1"
DEBUG    2021-10-30 19:27:40,148 [command.start:139]:SDL_VIDEO_FULLSCREEN_DISPLAY="off"
DEBUG    2021-10-30 19:27:40,148 [command.start:139]:DRI_PRIME="1"
DEBUG    2021-10-30 19:27:40,148 [command.start:139]:LD_LIBRARY_PATH="/lib/x86_64-linux-gnu:/lib/i386-linux-gnu:/lib32:/lib:/lib/i386-linux-gnu/i686/sse2:/lib/i386-linux-gnu/sse2:/usr/lib/x86_64-linux-gnu/libfakeroot:/lib64:/lib64:/usr/lib:/usr/lib64:/usr/lib32:/usr/lib64:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/laptop/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/lib:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
DEBUG    2021-10-30 19:27:40,149 [command.start:139]:game_name="Test 7zip"
DEBUG    2021-10-30 19:27:40,149 [command.start:139]:PYTHONPATH="/usr/lib/lutris:/usr/games:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages"
DEBUG    2021-10-30 19:27:40,149 [command.start:139]:LUTRIS_GAME_UUID="0602e8c7-c21a-438f-9b8c-6ec9a25a80f3"
INFO     2021-10-30 19:27:40,153 [game.start_prelaunch_command:370]:Running /media/storage/extract_test/extract_7zip_script.sh in the background
Started initial process 37213 from /media/storage/extract_test/extract_7zip_script.sh
Start monitoring process.
UNARCHIVING ROM

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_AU.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz (A0655),ASM,AES-NI)

Scanning the drive for archives:
1 file, 580038901 bytes (554 MiB)

Extracting archive: Moving Out [0100C4C00E73E000][v0].7z
--
Path = Moving Out [0100C4C00E73E000][v0].7z
Type = 7z
Physical Size = 580038901
Headers Size = 178
Method = LZMA2:14
Solid = -
Blocks = 1

Everything is Ok

Size:       580084672
Compressed: 580038901
Monitored process exited.
Initial process has exited (return code: 0)
All processes have quit
Exit with return code 0
DEBUG    2021-10-30 19:27:43,249 [command.on_stop:193]:Process 37211 has terminated with code 0
DEBUG    2021-10-30 19:27:44,159 [command.start:139]:DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1="1"
DEBUG    2021-10-30 19:27:44,159 [command.start:139]:SDL_VIDEO_FULLSCREEN_DISPLAY="off"
DEBUG    2021-10-30 19:27:44,159 [command.start:139]:DRI_PRIME="1"
DEBUG    2021-10-30 19:27:44,160 [command.start:139]:LD_LIBRARY_PATH="/lib/x86_64-linux-gnu:/lib/i386-linux-gnu:/lib32:/lib:/lib/i386-linux-gnu/i686/sse2:/lib/i386-linux-gnu/sse2:/usr/lib/x86_64-linux-gnu/libfakeroot:/lib64:/lib64:/usr/lib:/usr/lib64:/usr/lib32:/usr/lib64:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/laptop/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/lib:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/i386/usr/lib:/home/laptop/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/lib:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/laptop/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
DEBUG    2021-10-30 19:27:44,160 [command.start:139]:game_name="Test 7zip"
DEBUG    2021-10-30 19:27:44,160 [command.start:139]:PYTHONPATH="/usr/lib/lutris:/usr/games:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages"
DEBUG    2021-10-30 19:27:44,160 [command.start:139]:LUTRIS_GAME_UUID="4f45f2c6-472e-4489-a4df-9ef70d6c439b"
Started initial process 37229 from /usr/bin/xterm -e /home/laptop/.cache/lutris/run_in_term.sh
Start monitoring process.
ERROR    2021-10-30 19:27:46,202 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:27:48,201 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:27:50,205 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:27:52,203 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:27:54,203 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:27:56,204 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:27:58,204 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:28:00,205 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
ERROR    2021-10-30 19:28:02,205 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
DEBUG    2021-10-30 19:28:03,873 [command.on_stop:193]:Process 37227 has terminated with code 0
ERROR    2021-10-30 19:28:04,206 [process.environ:119]:Failed to parse environment variables: il local:/run/user/1000/klauncherIZCdaW.1.slave-socket local:/run/user/1000/dolphinZXOsos.153.slave-socket1
DEBUG    2021-10-30 19:28:04,207 [game.beat:588]:Game thread stopped
WARNING  2021-10-30 19:28:04,207 [game.on_game_quit:614]:Game still running (state: running)
INFO     2021-10-30 19:28:04,207 [game.stop:599]:Stopping Test 7zip (yuzu)
DEBUG    2021-10-30 19:28:04,207 [game.stop_game:554]:Test 7zip (yuzu) has run for 20 seconds
DEBUG    2021-10-30 19:28:04,216 [game.on_game_quit:632]:Test 7zip stopped at Sat, 30 Oct 2021 19:28:04
DEBUG    2021-10-30 19:28:04,216 [game.save:257]:Saving Test 7zip (yuzu) with config ID test-1635216155

I’ve been playing with the Yuzu runner in Lutris. It has been build with ROMS in mind. When manually adding a game it asks for a ROM file and when done an install button appears. That’s an install button, not a run button. I gather that this button installs the selected rom to the correct location for Yuzu to find it. An archived file won’t be recognized.

Yuzu itself can be run from terminal and I’ve seen examples of running a game directly. I think I would go in that direction.

~/.local/share/lutris/runners/yuzu/yuzu '~/yuzu-games/my-game/my-game.nsp'

My steps would probably look something like this:

  • Create bash script that picks a game archive from a repository location where I store all games as 7zips.
  • The script picks the game I want and extracts it to a temporary location. Possibly /tmp/something as the /tmp directory is cleaned at each boot and thus cleans things up rather nicely;
  • After extraction, yuzu is then called with the games rom location as an archument;
  • I would create desktop file. I’m running KDE and desktop files are text files which behave like a shortcut under Windows. An icon can be assigned there too.

I’ve got yuzu running but need to find a small rom to test with…

1 Like

Aaaah I see. Did I accidentally pick the most difficult emulator to try this with? :joy: Alright, I’ve got it working now! Finally! Thanks for your help! :grinning:

I have an idea of how to make this work without having to manage scripts for each individual game (unless I’m misunderstanding what your suggesting). I used the script below as a custom executable for yuzu instead of as a prelaunch script, it extracts the file and then opens it, but obviously only works if I am only ever playing one game with yuzu :joy: Can I dynamically reference the rom path (that was just extracted) instead of using a static rom path to launch yuzu? I only just started watching this course on bash scripting so don’t really understand how to use shell parametres enough to know if that’s possible or not :expressionless:

#!/bin/bash
echo "Extracting Game from Archive"
cd /media/storage/extract_test
for i in *.7z; do 7z x -o/media/storage/extract_test/cache "$i"; done
~/.local/share/lutris/runners/yuzu/yuzu '/media/storage/extract_test/cache/Moving Out [0100C4C00E73E000][v0].nsp'

Ah. Very nice. Well done!

Yes, you can pass command line arguments to a script. You could then possibly use the Custom executable for runner field in Lutris to paste the script in.

That call then would be like:

/home/username/run-yuzu-game.sh /media/storage/extract_test/ /media/storage/extract_test/cache/ "Moving Out [0100C4C00E73E000][v0].nsp"

The script would then be something like:

#!/bin/bash
echo "Extracting Game from Archive"
cd $1
for i in *.7z; do 7z x -o$2 "$i"; done
~/.local/share/lutris/runners/yuzu/yuzu '$2$3'

This is untested. You need to test whether Lutris will parse this correctly.

1 Like

Ah cool. Yeah I just figured out how the $0, $1, etc. work, so luckily that isn’t gibberish to me anymore :joy:

Hmm… is there a way to use the file name of game that lutris is launching as a variable (if I’m using the right term) in the script? For example, using the path of ROM.7z as a variable to make the script only extract that single file instead of all *.7z files in the directory, and then use the some $ROM to open the extracted .nsp file? Might look something like below, just don’t know how to get the file path being used by lutris in the first place…

#!/bin/bash
echo "Extracting Game from Archive"
for i in '$ROM'; do 7z x -o$2 "$i"; done
~/.local/share/lutris/runners/yuzu/yuzu '$2$ROM'

Assuming that’s possible, the file extensions of the extracted file will mess up $ROM in the final line, so I’d need to include something likesed to remove the archive extension and then add the file extensions used by the emulator.

#!/bin/bash
echo "Extracting Game from Archive"
for i in '$ROM'; do 7z x -o$2 "$i"; done
ROM_1="$ROM.nsp | sed 's/.7z//'"
ROM_2="$ROM.xci | sed 's/.7z//'"
~/.local/share/lutris/runners/yuzu/yuzu '$2$ROM_1'
~/.local/share/lutris/runners/yuzu/yuzu '$2$ROM_2'

And I know… my scripting is broken and garbage, just trying to make what I’m proposing sensible through an example :sweat_smile:

When only one 7z archive needs to be extracted, omit the for i in part.

/home/username/run-yuzu-game.sh "/media/storage/extract_test/Moving Out [0100C4C00E73E000][v0].7z" /media/storage/extract_test/cache/ "Moving Out [0100C4C00E73E000][v0].nsp"
  • $1 = location of the 7zip file you want to extract
  • $2 = target location
  • $3 = the filename of the ROM
#!/bin/bash
echo "Extracting Game from Archive"
7z x -o"$2" "$1"
~/.local/share/lutris/runners/yuzu/yuzu '$2$3'

With this set-up you define the names of all items in the Lutris game entry. For different games, create another game entry.

Calling yuzu twice will run yuzu twice.

I hope I followed what you are intending correctly. :thinking:

Yeah sorry, I’m not making myself easy to understand :sweat_smile: I guess I’m still figuring it all out more as I figure out how to script. What I’m trying to do (and hoping can be done!) is to have a single script to replace the executables for each emulator that will extract the rom without the necessity for having to pass custom command line arguments to the script, for each game. Mainly because it’s a lot of micromanagment, and it’d be easier to just extract all the roms manually probably :joy:

At the moment the only argument I really need to pass to the script is $1 because:

$2 can always = /media/storage/extract_test/cache/ for all extractions
$3 = /media/storage/extract_test/cache/ + the filename in $1, with the file extension changed from .7z to .nsp/.xci

So what I’m trying to figure out is if I can find the path of $1 without having to pass that argument to the script directly with a game specific argument. So mabye reading the filename from Lutris directly somehow? Maybe bash isn’t enough? Maybe I need to tinker with python? :expressionless:

:crossed_fingers: makes sense!

EDIT: Lutris prints that it’s starting a game and references the UUID, is that a way to find the pathname of the game? Really speculating here :joy: