How to detach lutris post script from lutris-wrapper

Hello
I have a pre-launch script which kills some of my background processes like my compositor (picom) and redshift.
On the post-launch script, I rerun these commands and everything works fine. The problem is that these programs, no matter what I do, are always a subprocess of lutris wrapper.

The problem is that lutris-wrapper eventually dies (when I close lutris, run another game, etc), taking my background processes with him.
I’ve tried

nohup picom &
setsid -f picom &
(picom &) &
...

image

To no avail, the program is still child of lutris-wrapper.

I’ve also tried to add the processes to the “Exclude Processes” box, doesnt work.
How can I resolve this problem?

Maybe adding the bg command to make it a background process? The jobs command can be used to monitor.

Check the command “disown”, i believe that is what you are looking for.

I had already tried disown.

Tried again with the scripts below, with and without nohup, didn’t work.

#!/bin/bash

pidof "redshift" || nohup redshift-sakura & disown
pidof "xautolock" || nohup xautolock-sakura & disown
pidof "picom" || nohup picom & disown
#!/bin/bash

pidof "redshift" || redshift-sakura &
pidof "xautolock" || xautolock-sakura &
pidof "picom" || picom &
disown -a

The script works when I execute it from the terminal, lutris is hugging those processes with all of his might

bg also didn’t work, I’m also not sure what’s happening, something to do with executing a process through python perhaps?

what happens if you disable the Lutris Runtime?

nothing, by the hover tip of lutris runtime, I don’t think it has something to do with lutris-wrapper. Not sure tho. Just to be sure, It also doesn’t work on your computer right?

shall I open an issue on github?

I have exactly the same issue that you have, did you manage to find a solution ?

Nohup and disown should have worked, but the lutris python wrapper probably doesn’t respect the process detachment.
One horrible solution that I thought of is to write a watcher that constantly runs separately, and in the launch script, poke or invoke the watcher to invoke the necessary processes.

The even more horrible but “nearly zero programming” version with no error checking is to run a script elsewhere that runs every 2s looking for a command file, and if that file appears, then runs the commands in it.
The lutris launch script creates that file and waits a small amount of time for the watcher to run it, then proceeds.

Thanks for your reply and your interesting solutions. Unfortunatly I don’t think I will go this way, and I don’t think the lutris maintainers will be ok to change how the wrapper works (cf this github issue).

On my case, I didn’t want to have a compositor background process, but an obs background process for recording automatically my games. The thing is, when the game stops, obs stops brutally, and I wanted a way to gently stop the recording and then stops obs with the post exit script. When obs stops brutally the mkv recording file is not written properly and when I read it in mpv or vlc I have some issue with the timeline.

Maybe I will not use the pre-launch script and just manually start obs each time I launch lutris and then stop the recording manually also.

That makes sense.
Unless it has an API, being able to stop obs “nicely” and shutdown behaviour would depend on how it responds to being sent signals.

If it is programmed to respond to shutdown nicely on stop (kill -15) or HUP (-1) then a stop script would work as an option and you wouldn’t need a detach as the post script would shutdown the pre-script.

Edit: I found a websocket add in, and a GitHub project that adds a wrapper called obs-cli
So it does have an API…kind of. Worth trying it out :slight_smile:

Thanks for that, I will go digging this way.

I think that I will just start obs every time I start lutris (editing the lutris.desktop to add obs) and then use obs-cli in pre-script and post-script to start and stop the recording.

1 Like