Fixes, sort group instances

This commit is contained in:
Natsumi
2025-01-14 00:58:20 +13:00
parent 5221b9d8c1
commit 885ead4edf
7 changed files with 103 additions and 42 deletions

View File

@@ -83,7 +83,29 @@ namespace VRCX
public override string GetClipboard()
{
return string.Empty;
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "xclip",
Arguments = "-o",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
try
{
process.Start();
var output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return output;
}
catch (Exception ex)
{
logger.Error($"Failed to get clipboard: {ex.Message}");
return string.Empty;
}
}
public override void SetStartup(bool enabled)

View File

@@ -22,6 +22,7 @@ namespace VRCX
static AppApiElectron()
{
const string vrchatAppid = "438100";
_homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
_steamPath = Path.Combine(_homeDirectory, ".local/share/Steam");
var flatpakSteamPath = Path.Combine(_homeDirectory, ".var/app/com.valvesoftware.Steam/.local/share/Steam");
@@ -31,39 +32,39 @@ namespace VRCX
_steamPath = flatpakSteamPath;
}
_steamUserdataPath = Path.Combine(_homeDirectory, ".steam/steam/userdata");
string vrchatAppid = "438100";
string libraryfoldersVdfPath = Path.Combine(_steamPath, "config", "libraryfolders.vdf");
string maybeSteamLibraryPath = null;
if (!File.Exists(libraryfoldersVdfPath))
var libraryFoldersVdfPath = Path.Combine(_steamPath, "config/libraryfolders.vdf");
var vrcLibraryPath = GetLibraryWithAppId(libraryFoldersVdfPath, vrchatAppid);
if (string.IsNullOrEmpty(vrcLibraryPath))
{
logger.Error("libraryfolders.vdf not found");
} else {
maybeSteamLibraryPath = GetLibraryWithAppId(libraryfoldersVdfPath, vrchatAppid);
}
string vrcLibraryPath = null;
if (maybeSteamLibraryPath == null)
{
logger.Warn("falling back to default VRChat path as libraryfolders.vdf was not found OR libraryfolders.vdf does not contain VRChat's appid (438100)");
logger.Warn("Falling back to default VRChat path as libraryfolders.vdf was not found OR libraryfolders.vdf does not contain VRChat's appid (438100)");
vrcLibraryPath = _steamPath;
} else {
logger.Info($"Using steam library path {maybeSteamLibraryPath}");
vrcLibraryPath = maybeSteamLibraryPath;
}
logger.Info($"Using steam library path {vrcLibraryPath}");
_vrcPrefixPath = Path.Combine(vrcLibraryPath, $"steamapps/compatdata/{vrchatAppid}/pfx");
_vrcAppDataPath = Path.Combine(_vrcPrefixPath, "drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat");
}
private static string? GetLibraryWithAppId(string pathToLibraryFolders, string appid)
private static string? GetLibraryWithAppId(string libraryFoldersVdfPath, string appId)
{
string? libraryPath = null;
foreach (var line in File.ReadLines(pathToLibraryFolders))
if (!File.Exists(libraryFoldersVdfPath))
return null;
foreach (var line in File.ReadLines(libraryFoldersVdfPath))
{
string? libraryPath = null;
// Assumes line will be \t\t"path"\t\t"pathToLibrary"
if (line.Contains("\"path\"")) libraryPath = line.Split("\t")[4].Replace("\"", "");
if (line.Contains("\"path\""))
{
var parts = line.Split("\t");
if (parts.Length < 4)
continue;
libraryPath = parts[4].Replace("\"", "");
}
if (line.Contains($"\"{appid}\"")) return libraryPath;
if (line.Contains($"\"{appId}\""))
return libraryPath;
}
return null;