diff --git a/Dotnet/AppApi/GameHandler.cs b/Dotnet/AppApi/GameHandler.cs index 0a399559..1ca86af9 100644 --- a/Dotnet/AppApi/GameHandler.cs +++ b/Dotnet/AppApi/GameHandler.cs @@ -27,9 +27,24 @@ namespace VRCX var isGameRunning = false; var isSteamVRRunning = false; - if (ProcessMonitor.Instance.IsProcessRunning("VRChat")) + if (Wine.GetIfWine()) { - isGameRunning = true; + var wineTmpPath = Path.Combine(Program.AppDataDirectory, "wine.tmp"); + if (File.Exists(wineTmpPath)) + { + var wineTmp = File.ReadAllText(wineTmpPath); + if (wineTmp.Contains("isGameRunning=true")) + { + isGameRunning = true; + } + } + } + else + { + if (ProcessMonitor.Instance.IsProcessRunning("VRChat")) + { + isGameRunning = true; + } } if (ProcessMonitor.Instance.IsProcessRunning("vrserver")) diff --git a/Dotnet/Wine.cs b/Dotnet/Wine.cs index 9a3215a4..39344a1d 100644 --- a/Dotnet/Wine.cs +++ b/Dotnet/Wine.cs @@ -1,23 +1,23 @@ using System; using System.Runtime.InteropServices; -namespace VRCX; - -public static class Wine +namespace VRCX { - [DllImport("ntdll.dll")] - private static extern IntPtr wine_get_version(); - - public static bool GetIfWine() + public static class Wine { - // wine_get_version should be guaranteed to exist exclusively in Wine envs, - // unlike some other suggestions like checking Wine registry keys - try - { - wine_get_version(); - return true; - } - catch { return false; } - } -} + [DllImport("ntdll.dll")] + private static extern IntPtr wine_get_version(); + public static bool GetIfWine() + { + // wine_get_version should be guaranteed to exist exclusively in Wine envs, + // unlike some other suggestions like checking Wine registry keys + try + { + wine_get_version(); + return true; + } + catch { return false; } + } + } +} \ No newline at end of file diff --git a/Linux/install-vrcx.sh b/Linux/install-vrcx.sh index 76b6a31e..e38d9e85 100644 --- a/Linux/install-vrcx.sh +++ b/Linux/install-vrcx.sh @@ -83,6 +83,11 @@ cp seguiemj.ttf "$WINEPREFIX/drive_c/windows/Fonts" WINEPREFIX=$WINEPREFIX wine reg add 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts' /v 'seguiemj' /t REG_SZ /d 'seguiemj.ttf' /f rm seguiemj.ttf +curl -L https://raw.githubusercontent.com/vrcx-team/VRCX/master/Linux/vrcx.sh -o $WINEPREFIX/drive_c/vrcx.sh +chmod +x $WINEPREFIX/drive_c/vrcx.sh + +curl -L https://raw.githubusercontent.com/vrcx-team/VRCX/master/Linux/winediscordipcbridge.exe -o $WINEPREFIX/drive_c/winediscordipcbridge.exe + echo "Install VRCX.png to $XDG_DATA_HOME/icons" curl -L https://raw.githubusercontent.com/vrcx-team/VRCX/master/VRCX.png -o "$XDG_DATA_HOME/icons/VRCX.png" @@ -91,7 +96,7 @@ echo "[Desktop Entry] Type=Application Name=VRCX Categories=Utility; -Exec=WINEPREFIX=$WINEPREFIX wine '$INSTALL_LOCATION/VRCX.exe' +Exec=$WINEPREFIX/drive_c/vrcx.sh Icon=VRCX " > $XDG_DATA_HOME/applications/vrcx.exe.desktop diff --git a/Linux/vrcx b/Linux/vrcx new file mode 100755 index 00000000..e626f139 --- /dev/null +++ b/Linux/vrcx @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +export WINEPREFIX=~/.local/share/vrcx + +wine ~/.local/share/vrcx/drive_c/winediscordipcbridge.exe & +IPCBRIDGE_PID=$! + +wine ~/.local/share/vrcx/drive_c/vrcx/VRCX.exe & +VRCX_PID=$! + +while kill -0 $VRCX_PID 2>/dev/null; do + if ps -A | grep -i "VRChat.exe" > /dev/null; then + isGameRunning=true + else + isGameRunning=false + fi + echo "isGameRunning=$isGameRunning" > "$WINEPREFIX/drive_c/users/$USER/AppData/Roaming/VRCX/wine.tmp" + sleep 1 +done + +echo "isGameRunning=false" > "$WINEPREFIX/drive_c/users/$USER/AppData/Roaming/VRCX/wine.tmp" + +kill $IPCBRIDGE_PID 2>/dev/null \ No newline at end of file diff --git a/Linux/winediscordipcbridge.exe b/Linux/winediscordipcbridge.exe new file mode 100644 index 00000000..1eb725f6 Binary files /dev/null and b/Linux/winediscordipcbridge.exe differ diff --git a/html/src/classes/updateLoop.js b/html/src/classes/updateLoop.js index 574ee4f3..6be586f6 100644 --- a/html/src/classes/updateLoop.js +++ b/html/src/classes/updateLoop.js @@ -22,7 +22,8 @@ export default class extends baseClass { ipcTimeout: 0, nextClearVRCXCacheCheck: 0, nextDiscordUpdate: 0, - nextAutoStateChange: 0 + nextAutoStateChange: 0, + nextGameRunningCheck: 0, }; _methods = { @@ -75,6 +76,10 @@ export default class extends baseClass { this.nextAutoStateChange = 3; this.updateAutoStateChange(); } + if (--this.nextGameRunningCheck <= 0) { + this.nextGameRunningCheck = 3; + AppApi.CheckGameRunning(); + } } } catch (err) { API.isRefreshFriendsLoading = false;