[Python] Is there a way to execute code from a sh when the shell gets force closed

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently working on my own cloud save system for nonsteam games. Currently I need a way to backup the game files when I press "STOP" on steam, which closes what ever executable is used to launch. Here is an example of what doesn't work:

    cd "/location_of_backups/"
    py savemanager.py --load --auto-override --force
    Ryujinx.exe "path/to/game.nsp"
    #if you press CLOSE on steam this never executes
    py savemanager.py --backup
    # Ryujinx.exe "path/to/game.nsp" && py savemanager.py --backup neither does this
    # anything that launches in a seprate shell also doesnt work


    the core of the issue is, the shell file itself gets force closed, is there a way to execute code when this specific shell gets closed? Thanks.

    EDIT 1: for clarification, I am opening this shell script through steam. It's bascily a wrapper to open an emulated game but also load and backup my saves. The problem is actually two fold and I shouldve clarified. I absoltetly need the emulator to launch as/in the main process, as steam attaches the overlay to the original instance.

    Extra Info : this is bascily used to sync files on my main PC and my steamdeck

    Continue reading...

Compartilhe esta Página