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:
rs189
2024-12-01 11:00:30 +00:00
committed by GitHub
parent cd42a9a207
commit 5e6c611264
6 changed files with 69 additions and 21 deletions
+17 -2
View File
@@ -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"))
+17 -17
View File
@@ -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; }
}
}
}