HGL
like-gold
[Solved] Running a shell script before launching a game and after exiting that game
I thought it will be easy to do that as there's already options for both (launch & exit). But I cant get it to work. I wanna use ludusavi which was installed using flatpak.
Ludusavi already had a guide for heroic but I cant get it to work so I was thinking about creating my own script.
Heroic is installed as native package.
Distro: Fedora 42 KDE
35 Replies
like-goldOP•2mo ago
I am trying to use this.
right now running
ludusavi-wrapper.sh backup "Assassins Creed IV Black Flag"
in terminal works and the script exit with 0
but if I put this in "Select a script to run before the game is launched" then its stucked in launching state
I would also like to get the game name from heroic if thats possible
when I run heroic via cli i found this when launching the game
Error occurred in handler for 'launch': spawn ~/games/.tools/ludusavi-wrapper.sh backup "Assassins Creed IV Black Flag" ENOENT
I did added path and heroic should have access to this
Error occurred in handler for 'launch': spawn flatpak run com.github.mtkennerly.ludusavi --config $HOME/.var/app/com.github.mtkennerly.ludusavi/config/ludusavi backup --force "Assassins Creed IV Black Flag" ENOENT
if I just add the commandYou can't run a Flatpak from another Flatpak
Add
flatpak-spawn --host
to the start of your command to execute the command on the host instead. Note that this requires the org.freedesktop.Flatpak
talk and essentially disables the advantages of Flatpak
To grant that talk permission, run
like-goldOP•2mo ago
Heroic isnt installed as flatpak
Oh sorry, missed that note. I only read "I did added path and heroic should have access to this" and figured Flatpak
I assume the script you created is executable?
like-goldOP•2mo ago
yep I tested manually before adding
and looks like backup portion is working as I haven't tested restore yet
Looking at the code, I don't think scripts can have parameters
You should be able to do this though: https://github.com/mtkennerly/ludusavi/blob/master/docs/help/game-launch-wrapping.md#heroic (perhaps with slight changes since you're using the Flatpak Ludusavi)
like-goldOP•2mo ago
Sorry I am new to scripting dont know much as I said I was able to get it work when I ran it.
I created another post too
https://discord.com/channels/812703221789097985/1394735173282697236/1394735173282697236
this didnt explain much and idk how to add this wrapper. is it similar to adding script ?
Create the file as instructed there, replacing
ludusavi
with flatpak run com.github.mtkennerly.ludusavi
since you're on Flatpak
Then add that script as a wrapper in Heroic ("Wrapper command" in the "Advanced" tab of the game settings)like-goldOP•2mo ago
I assume
here
ludusavi
has to be changed to latpak run com.github.mtkennerly.ludusavi
config dir to $HOME/.var/app/com.github.mtkennerly.ludusavi/config/ludusavi
but I wasn't able to get it to work
but let me try againlike-goldOP•2mo ago
does it look ok?

Just add the script as the wrapper, no arguments
like-goldOP•2mo ago
Did as you said
Oh actually, I don't think you can use
~
like-goldOP•2mo ago
$HOME
then ?
lemme tryAssuming
~/.local/bin/test/
is on your PATH
, you should be able to just add ludusavi-wrapper.sh
No, you'd have to write out the actual pathlike-goldOP•2mo ago
from /home/*?
/home/your_username/.local/bin/test/ludusavi-wrapper.sh
, replacing your_username
with your actual user's namelike-goldOP•2mo ago
yep tried now ludusavi can find the game
like-goldOP•2mo ago

like-goldOP•2mo ago

like-goldOP•2mo ago
if I say yes then I get crash notification
BTW is it possible to get the game name from heroic ?
Yeah figured, Ludusavi's Flatpak doesn't include Wine dependencies... The easiest way to resolve this would probably be to just use the native Ludusavi
like-goldOP•2mo ago
Alright . But I have never tried building from source
https://github.com/mtkennerly/ludusavi/releases/download/v0.29.1/ludusavi-v0.29.1-linux.tar.gz
idk how to use this, using llm i got to know that I can use it as any other script. this one is just compiled .
does it mean if I put it in my script folder I can run normally ?
sorry for the noob question
This doesn't say if its rpm or deb build
It isn't a package, it's simply an executable
However depending on your distro, there might be a package for it in the official repos
like-goldOP•2mo ago
I tried looking for copr and rpmfusion and official there's none
Also, please do not use LLMs to attempt to get help here. They will lie to you
like-goldOP•2mo ago
yes thats why I didn't try using that file
I just use those to get direction then try to do my research
Whats the difference then ?
similar to running script or installing something ?
Right, manual install it is then. Download the release (https://github.com/mtkennerly/ludusavi/releases/download/v0.29.1/ludusavi-v0.29.1-linux.tar.gz), then extract it and place the executable into
~/.local/bin/
. Run a chmod +x ~/.local/bin/ludusavi
to mark it as executable
I assume ~/.local/bin
is on your PATH
. To check, open a terminal now and run which ludusavi
. If that command finds it, you're good
Open up your ludusavi-wrap.sh
script and change it to match the contents of the guide again (replacing flatpak run ...
with just ludusavi
like-goldOP•2mo ago
yep done that
it looks like ludusavi still cant recognize the game. I did have this issue if name isn't same or what ludusavi expect when I was in windows.
BTW is there a way to know what heroic launches ? in this way I can create an alias in ludusavi
This time I was able to launch when I pressed yes
it looks like ludusavi still cant recognize the game. I did have this issue if name isn't same or what ludusavi expect when I was in windows.Could you send in a game log?
BTW is there a way to know what heroic launches ? in this way I can create an alias in ludusaviI'm not sure what you're asking there. Heroic will launch the game with either Legendary (for Epic Games), GOGDL (for GOG) or Nile (Amazon)
like-goldOP•2mo ago
Sorry IDK where the log is
To help you, we need a game log. Please see the following images on how to get it.






like-goldOP•2mo ago
Now it looks like with the wrapper script I cant launch the game anymore. BTW this is a non heroic game. I had it installed in my old windows partition and copied over
https://0x0.st/8djt.log
Sideloaded games probably won't work with Ludusavi. It doesn't have any metadata to find out the game you're playing
like-goldOP•2mo ago
Oh I see but dev suggested for emulators I can do it by adding custom games.
BTW ig I should give it a try with my script earlier see if that works
Thanks for your time
But any idea why the script wont work that way ?
The fix can be found here.
https://discord.com/channels/812703221789097985/1395767977093238854