Launch script to run kscreen-doctor command on game startup erroring out

I am attempting to use a startup script on game launch that scales my screen to 200% using kscreen-doctor. The script functions when executed outside of heroic games launcher, but when heroic games launcher tries to run it itself it produces the following error in the logs:

Running script before Avernum: Escape From the Pit (/home/hkr/Games/Heroic/Avernum - Escape From The Pit/scale200.bash) /home/hkr/Games/Heroic/Avernum - Escape From The Pit/scale200.bash: line 2: kscreen-doctor: command not found

here is the full script:

#!/bin/bash kscreen-doctor output.DP-1.scale.2.00

I am running Heroic Games Launcher as a flatpak from the bazzite bazaar.
Solution
For those searching for something similar in the future, the solution is to run the script with

flatpak-spawn --host kscreen-doctor [arguments]

In flatseal, you need to add org.freedesktop.Flatpak

to the talks section under Session Bus.
Was this page helpful?