mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 23:03:51 +02:00
Linux: fix open folder and select item (#1288)
* fix: open folder and select item on linux * fix: crash dumps folder button on linux * Rename AppData --------- Co-authored-by: Natsumi <cmcooper123@hotmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ namespace VRCX
|
||||
public static string _steamUserdataPath;
|
||||
public static string _vrcPrefixPath;
|
||||
public static string _vrcAppDataPath;
|
||||
public static string _vrcCrashesPath;
|
||||
|
||||
static AppApiElectron()
|
||||
{
|
||||
@@ -52,6 +53,7 @@ namespace VRCX
|
||||
logger.Info($"Using steam library path {vrcLibraryPath}");
|
||||
_vrcPrefixPath = Path.Join(vrcLibraryPath, $"steamapps/compatdata/{vrchatAppid}/pfx");
|
||||
_vrcAppDataPath = Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat");
|
||||
_vrcCrashesPath = Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/AppData/Local/Temp/VRChat/VRChat/Crashes");
|
||||
}
|
||||
|
||||
private static string? GetLibraryWithAppId(string libraryFoldersVdfPath, string appId)
|
||||
@@ -234,8 +236,12 @@ namespace VRCX
|
||||
|
||||
public override bool OpenCrashVrcCrashDumps()
|
||||
{
|
||||
// TODO: get path
|
||||
var path = _vrcCrashesPath;
|
||||
if (!Directory.Exists(path))
|
||||
return false;
|
||||
|
||||
OpenFolderAndSelectItem(path, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OpenShortcutFolder()
|
||||
@@ -252,22 +258,25 @@ namespace VRCX
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
return;
|
||||
|
||||
var directoryPath = isFolder ? path : Path.GetDirectoryName(path);
|
||||
string directoryPath = isFolder ? path : Path.GetDirectoryName(path);
|
||||
var commandAttempt = new Dictionary<string, string>
|
||||
{
|
||||
{ "nautilus", path },
|
||||
{ "nemo", path },
|
||||
{ "thunar", path },
|
||||
{ "nautilus", $"\"{path}\"" },
|
||||
{ "nemo", $"\"{path}\"" },
|
||||
{ "thunar", $"\"{path}\"" },
|
||||
{ "caja", $"--select \"{path}\"" },
|
||||
{ "pcmanfm-qt", directoryPath },
|
||||
{ "pcmanfm", directoryPath },
|
||||
{ "pcmanfm-qt", $"\"{directoryPath}\"" },
|
||||
{ "pcmanfm", $"\"{directoryPath}\"" },
|
||||
{ "dolphin", $"--select \"{path}\"" },
|
||||
{ "konqueror", $"--select \"{path}\"" },
|
||||
{ "xdg-open", directoryPath }
|
||||
{ "xdg-open", $"\"{directoryPath}\"" }
|
||||
};
|
||||
|
||||
foreach (var command in commandAttempt)
|
||||
{
|
||||
if (!IsCommandAvailable(command.Key))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
var process = new Process
|
||||
@@ -276,22 +285,48 @@ namespace VRCX
|
||||
{
|
||||
FileName = command.Key,
|
||||
Arguments = command.Value,
|
||||
UseShellExecute = true,
|
||||
CreateNoWindow = true
|
||||
UseShellExecute = false,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardOutput = true,
|
||||
CreateNoWindow = true,
|
||||
}
|
||||
};
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
if (process.ExitCode == 0)
|
||||
return;
|
||||
return; // Assume first successful start is enough
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
// ignore the error and try the next command
|
||||
// Ignore and try next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsCommandAvailable(string command)
|
||||
{
|
||||
try
|
||||
{
|
||||
var which = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "which",
|
||||
Arguments = command,
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
}
|
||||
};
|
||||
which.Start();
|
||||
string result = which.StandardOutput.ReadToEnd();
|
||||
which.WaitForExit();
|
||||
return which.ExitCode == 0 && !string.IsNullOrWhiteSpace(result);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task<string> OpenFolderSelectorDialog(string defaultPath = "")
|
||||
{
|
||||
// TODO: Implement
|
||||
|
||||
@@ -1404,10 +1404,10 @@
|
||||
<div class="options-container-item" style="margin-top: 15px">
|
||||
<el-button-group>
|
||||
<el-button size="small" icon="el-icon-folder" @click="openVrcxAppDataFolder()"
|
||||
>AppData (VRCX)</el-button
|
||||
>VRCX Data</el-button
|
||||
>
|
||||
<el-button size="small" icon="el-icon-folder" @click="openVrcAppDataFolder()"
|
||||
>AppData</el-button
|
||||
>VRChat Data</el-button
|
||||
>
|
||||
<el-button size="small" icon="el-icon-folder" @click="openCrashVrcCrashDumps()"
|
||||
>Crash Dumps</el-button
|
||||
|
||||
Reference in New Issue
Block a user