Lutris re-opens after launching game

I have a global pre-launch script that pauses my gif wallpaper and a global post-exit script that resumes the wallpaper. I have “Minimize client when a game is launched” enabled. When I run a game (with Steam as the runner, although I have not tested this with a non-Steam game yet), Lutris minimizes for a moment, but reopens after a few seconds. Once it reopens, the “Stop” button in the bottom left of the screen changes to say “Play,” and my post-exit script runs, even though the game is still running. Is this expected behavior or a bug? I am more concerned about my post-exit script; I would like for it to run when I have actually closed the game I am playing.

Here’s a video of the behavior: https://vimeo.com/1235628201?share=copy&fl=sv&fe=ci

Yeah this is a problem with steam. Launching steam just tells steam to launch (and launch the game) and then exits - lutris doesn’t see how or if steam responds to that.
The only way to get what you describe you want with a steam game is to use the launch arguments in steam. You’ll probably need to write a custom script for that, of the form:

insertcommandstopausethewallpaper
$@
insertcommandstoresumethewallpaper

then call that something like pausewallpaper.sh, make it executable and place it in /usr/local/bin (or any other directory added to your path). In steam, under properties→launch options, add pausewallpaper.sh %COMMAND%.

Limitations: there’s no way to do it globally, you need to add it to every game. Also, the unpause wallpaper part does not run if you kill the game using the “stop” button in steam.

For extra features: if you want to have this run only when launched through lutris, you can launch it with some custom variable set (say, env LAUNCHEDTHROUGHLUTRIS=1) and add a check in the above script to both only pause and only resume the wallpaper if that variable is 1.
If you want to exit steam after the game exits, you can add killall steam to the end of the script, that’ll tell steam to shut down - though it’ll still do the annoying thing where it brings itself to the front to tell you that it’s shutting down.
If you absolutely want this to run whenever a game is running, it’d almost be best to try and write a custom service that regularly checks if a game is running and pauses the desktop if it is. I don’t know how you’d do that practically though - I don’t know if there is a good way to reliably tell if a game is running.

I think, if you make sure to kill steam after every game, you could make this work. I just tested it and if steam wasn’t running (and this includes minimised to tray - run killall steam to be sure it’s gone) then lutris will see steam launching and wait with a post exit script - not until the game stops, but until steam itself stops. Problem with that is that you still have to manually add some post-exit steam kill to each game you want this to work for. At which point, you can just add a wallpaper unfreeze to each game…

i’ll try that out.

update: launching my games now sometimes launches steam in big picture mode for some reason (even though i have the option disabled in lutris). but when this happens, my pre and post exit scripts do work as intended.

Huh, that’s odd. Maybe the way lutris launches steam launches it in big picture mode?

it only does it sometimes, though…

I wrote a bash script for my system which mounts 4 network drives on a server I have elsewhere in the house, but only on when woke via lan. It’s simple, there four commands mounting the SMB shares. I can run that at the command line and the script works perfect. The script has the sudo user/pass on each line for all the drives, in the clear (please don’t lecture me about security) and that works fine. Making a shortcut to it on the KDE start menu fails to run. I have not looked into it very much since this isn’t a big deal as long as the script works. But it appears every time you call one script from another, selinux sticks its ugly head in there and makes yet another layer of headaches. I wonder if your problem isn’t related and is actually the OS “keeping you safe…”