Run a script when entering/exiting a game

I think I might be overcomplicating things but for the life of me I can't seem to figure this out. Bazzite installed in a SteamDeck OLED. I want to run a script when I execute a specific game and the same one with different parameters when I exit it. The purpose is some home automation stuff. I thought "Okay, this shouldn't be hard". Checked $PATH and there's /home/<my-user>/.local/bin and also noticed that /home/deck is a symlink to /home/<my-user>. So I wrote a script that uses curl to send a payload and placed it there. Marked it as executable (and eventually just went full on 777) and tested it in the terminal. All good. Works. Then I went to game mode -> Game -> Launch options -> script.sh true; %command%; script.sh false. But it doesn't do anything. The game launches yeah but the script doesn't seem to ever get executed, or at least I don't see the incoming webhook call on the other side. Tried: * script.sh <value> * /home/<my-user>/.local/bin/script.sh <value> * /home/deck/.local/bin/script.sh <value> * ~/.local/bin/script.sh <value> * All of the above but with sh -c "examples above here". Any hints on how I can troubleshoot this?.
3 Replies
Raevenant
Raevenant5w ago
I've been trying to use a script that passes execution after, but I can't get it to work either. Here's my current attempt
#!/usr/bin/env bash
reset_fan() {
send-notify "fan control lazy"
fw-fanctrl set lazy
}
trap reset_fan EXIT
send-notify "fan control medium"
fw-fanctrl set medium
$@
#!/usr/bin/env bash
reset_fan() {
send-notify "fan control lazy"
fw-fanctrl set lazy
}
trap reset_fan EXIT
send-notify "fan control medium"
fw-fanctrl set medium
$@
Theoretically it would be script %command% but it doesn't work In my case, the script runs, but then the game crashes I've been using send-notify to see if the script runs
Laura
LauraOP5w ago
MMm okay, different issue haha. In your case, if the script runs properly, I would remove the $@ at the end of your script and set the launch option to /path/to/the/script; %command%. Should achieve running it then running the game afterward. Hadn't thought about send-notify to troubleshoot it. That's a good one. Where are you placing the script @Raevenant ?
Raevenant
Raevenant4w ago
Just anywhere in the $PATH really Could always do the full path ig So I mean, the $@ works just fine with vkube, so idk why it doesn't work for a steam game @Laura I figured it out! So the method I'm using doesn't work on non-GE-proton games. Linux native games work just fine, and GE-proton run games work just fine. For whatever reason, base proton doesn't let scripts run

Did you find this page helpful?