mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 06:13:52 +02:00
Linux: Make Discord Rich Presence work (#998)
* Linux: Make Discord Rich Presence work * Fix file already exists * Fix chmod file name
This commit is contained in:
@@ -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"))
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
23
Linux/vrcx
Executable file
23
Linux/vrcx
Executable file
@@ -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
|
||||
BIN
Linux/winediscordipcbridge.exe
Normal file
BIN
Linux/winediscordipcbridge.exe
Normal file
Binary file not shown.
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user