diff --git a/fix-wm-class.sh b/fix-wm-class.sh index fd2c488..13f0d28 100755 --- a/fix-wm-class.sh +++ b/fix-wm-class.sh @@ -1,3 +1,25 @@ -#!/bin/sh -WM_CLASS="$([ "$2" ] && echo "$2" || echo "$1")" -xdotool search --sync --name "$1" set_window --classname "$WM_CLASS" --class "$WM_CLASS" %@ +#!/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 + +WM_CLASS=$WM_NAME_ALT + +echo "Starting process: $@" >> $LOG_FILE +"$@" & + +PID=$! +echo "Process ID: $PID" >> $LOG_FILE + +while kill -0 $PID 2> /dev/null; do + xdotool search --sync --name "$WM_NAME" set_window --classname "$WM_CLASS" --class "$WM_CLASS" %@ + echo "Process still running: $(date)" >> $LOG_FILE + sleep 1 +done +exit 0 \ No newline at end of file diff --git a/sif.py b/sif.py index 77363dd..6d0c15d 100755 --- a/sif.py +++ b/sif.py @@ -202,18 +202,24 @@ def fix_launch_option(app_id, wm_name, wm_name_alt=""): app = apps[app_id] if "LaunchOptions" not in app.keys(): app["LaunchOptions"] = "" - app["LaunchOptions"] = sub("&\\s/.*fix-wm-class\\.sh.*?;", "", app["LaunchOptions"]) + app["LaunchOptions"] = sub("\\s/.*fix-wm-class\\.sh.*?;", "", app["LaunchOptions"]) + app["LaunchOptions"] = sub("%command%", "", app["LaunchOptions"]) + launch_options = app["LaunchOptions"].strip() script = str(WM_CLASS_FIXER_SCRIPT) if wm_name_alt: - app["LaunchOptions"] += '& %s "%s" "%s";' % ( + app["LaunchOptions"] = '%s %s "%s" "%s" %%command%%;' % ( + launch_options, script, wm_name, wm_name_alt, ) - elif wm_name == "Pillars of Eternity": - app["LaunchOptions"] += '& sleep 5 && %s "%s";' % (script, wm_name) else: - app["LaunchOptions"] += '& %s "%s";' % (script, wm_name) + app["LaunchOptions"] = '%s %s "%s" "%s" %%command%%;' % ( + launch_options, + script, + wm_name, + wm_name, + ) vdf.dump(loaded, open(conf_file, "w"), pretty=True) @@ -231,7 +237,8 @@ def restore_launch_options(): for app_id in apps.keys(): app = apps[app_id] if "LaunchOptions" in app.keys(): - app["LaunchOptions"] = sub("&\\s/.*fix-wm-class\\.sh.*?;", "", app["LaunchOptions"]) + app["LaunchOptions"] = sub("\\s/.*fix-wm-class\\.sh.*?;", " %command%", app["LaunchOptions"]) + app["LaunchOptions"] = app["LaunchOptions"].strip() vdf.dump(loaded, open(conf_file, "w"), pretty=True) @@ -717,7 +724,7 @@ def quit_handler(_, __): if steam_detected: print_warning("\nSome games couldn't be fixed due to running Steam.\nExit Steam and try it again.") else: - print("\n * - added fix to game launch options") + print("\n * - added fix to game launch options. Double check your launch options just in case.") if options.pretend: print_warning("\nNo changes were made because --pretend option was used.")