-
Notifications
You must be signed in to change notification settings - Fork 6
Made fix-wm-class.sh run as long as game is running. #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In order to move away from the per game sleep method, I have made it so that fix-wm-class.sh now runs as long as the reaper wrapper process is still running. Should work in 99.9% of cases, tested with UNDERTALE and Pillars.
|
Hello, thanks for taking the initiative on this — not bad at all for your first steps into shell scripting! Your script works, but the main issue is that To make this more generic, we should avoid using any specific process names in the script. One idea is to leverage Steam’s |
Yeah, I figured it would be best to leverage Steam's Do you know of a way to get the %command% programmatically? |
I did some research into this. I recently started using a rust program called |
|
Hi! Sorry for the late reply to your earlier question. Getting the content of As for using process names, I’m not a big fan of that approach, just like I’m not a fan of relying on the reaper process itself. The main problem is that if you launch more than one game, it becomes difficult to tell which reaper process belongs to which game. I believe we can find a cleaner solution. To illustrate the idea I mentioned earlier, I wrote a simple proof-of-concept script: #!/usr/bin/env sh
LOG_FILE="/tmp/steam_watcher.log"
echo "Starting process: $@" > $LOG_FILE
"$@" &
PID=$!
echo "Process ID: $PID" >> $LOG_FILE
while kill -0 $PID 2> /dev/null; do
echo "Process still running: $(date)" >> $LOG_FILE
sleep 1
doneTo try it out, save the following script as You can then test it immediately with any GUI application. For example: ./process_watcher.sh firefoxIn a separate terminal, you can view the log: cat /tmp/steam_watcher.logYou’ll see something like this, with new lines continuously added while the firefox process is running: This can also be used in a Steam game's launch options: Printing the log after launching the game: cat /tmp/steam_watcher.logwill output something like this: Do you think you'll be able to implement this into |
…ocess is ended. It extracts the last parameter as the Window Class, so the usasge needs to be fix-wm-class.sh %command% "WM_CLASS". Additionally, it works with gamemoderun, from what little testing I did. However, gamemoderun needs to go before everything else: gamemoderun fix-wm-class.sh %command% "WM_CLASS". Will work on the python script to fix that next.
Finds all instances of %command% in an existing launch option array, and removes them. Strips out any excess whitespace and stores the launch options. Instead of appending to the existing options, the options are now overridden, with any existing options (barring %command%) going before fix-wm-class.sh. This is to facilitate the usage of things like mangohod or gamemoderun. for instance, say a game's launch options are currently gamemoderun %command%. Upon running sif.py, the new command will be gamemoderun PATH_TO_SIF/fix-wm-class.sh %command% WM_CLASS; Tested witn UNDERTALE and Pillars of Eternity. I do not know if it will work with WM_CLASS_ALT games, as at the moment fix-wm-class treats the very last argument it receives as WM_CLASS regardless of anything else.
|
Updated both fix-wm-class.sh and sif.py. Tested with UNDERTALE and Pillars of Eternity, seems to be working. Let me know if you want anything else changed! |
|
Let me know when you've had a chance to look, I'm eager to get this pull request finished |
|
Hi, great work! This is looking almost ready to merge. There are just two remaining issues that need to be addressed before we can wrap this up:
|
|
Sure, I'll get on that as soon as I'm free |
|
Update: The quote around %command% solution breaks functionality, even with double quotes, due to the command having a new line in it. I wrote a wrapper that just logs the entire %command%. Without quotes, the value of With quotes (and double quotes), it becomes: As you can see, UNDERTALE is here (I was testing fix-wm class), but all of the post new line output is discarded entirely if passed as a string. Amusingly, this results in the command changing the icon of steam instead of Undertale. Indeed, Undertale doesn't launch at all due to the lack of the steam-launch-wrapper properly running. Advise? |
I've fixed sif.py to account for the new launch options. I don't know much about regexes, so it *might* be a bit hacky, feel free to change it to be more optimal. However, I am still struggling with fix-wm-class.sh. It turns out, if you surround %command% with quotes, steam automatically inserts 'single quotes' around some of the arguments, breaking the %command%. Double quoting makes it even more nested. Regardless, fix-wm-class.sh now works with Undertale... But not with Pillars of Eternity. The game simply never launches. I suspect the spaces in the folder's name are responsible, so I tried launching it without removing the single quotes it generated. That did not change anything. Interestingly, Steam thinks POE is running without the single quote in args; otherwise, it instantly closes. Finally, I have to launch with $@. "$@" causes neither Undertale nor PoE to launch. Need advice.
|
Disregard #50 (comment). Turned out to be irrelevant. Still having issues, however. Please read latest commit message for details. |
|
You're right - I just tested it. If I use Could you slightly modify the behavior, so that we always pass #!/usr/bin/env sh
LOG_FILE="/tmp/steam_watcher.log"
WM_NAME=$1
echo "WM_NAME: $WM_NAME" > $LOG_FILE
shift
WM_NAME_ALT=$1
echo "WM_NAME_ALT: $WM_NAME_ALT" >> $LOG_FILE
shift
echo "Starting process: $@" >> $LOG_FILE
"$@" &
PID=$!
echo "Process ID: $PID" >> $LOG_FILE
while kill -0 $PID 2> /dev/null; do
echo "Process still running: $(date)" >> $LOG_FILE
sleep 1
donePlease note that the Also, please note that I'm using the shift command to discard the first argument, rather than splitting the arguments with |
|
Sure thing, I'll try it out. |
Should work now. One potential issue, any command line arguments after %command% will be stripped away along with everything after fix-wm-class.sh when running SIF. I can also see a scenario where, say a game runs like:
`gamemoderun %command% --some-arg`
SIF, if fix-window-class has never been run before, will likely put
`gamemoderun --some-arg fix-wm-class.sh %command%`
I think this will not work. That said, I don't have enough experience with regexes to fix this, and it's a bit beyond the scope of this change, I think. I believe we should merge this, and handle that behavior in another PR potentially? Alternatively I can try to make it work if pointed in the right direction. For now, I added a message to the users to double check their launch options (which I think they should do anyway):
`print("\n * - added fix to game launch options. Please double check to ensure your launch options are correct.")`
|
Done. There's one lingering issue left detailed in the commit, but I added a user warning to hopefully mitigate it for now. I think it can be fixed separate from this PR, however. |
|
Thank you for the changes. Merging |
The reason I check if reaper is running is because it is more reliable. Pillars seems to spawn multiple processes, and I'm not sure which to track, due to how it launches. There's also a delay between when reaper launches and when the game launches. However, reaper will always close when the game closes, so it's reliable in 99.9% of cases (if a user has disabled the steam wrapper though, I'm not sure what we can do).
I'm new to Linux and bash, so let me know if this is inefficient.