mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-22 00: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 _steamUserdataPath;
|
||||||
public static string _vrcPrefixPath;
|
public static string _vrcPrefixPath;
|
||||||
public static string _vrcAppDataPath;
|
public static string _vrcAppDataPath;
|
||||||
|
public static string _vrcCrashesPath;
|
||||||
|
|
||||||
static AppApiElectron()
|
static AppApiElectron()
|
||||||
{
|
{
|
||||||
@@ -52,6 +53,7 @@ namespace VRCX
|
|||||||
logger.Info($"Using steam library path {vrcLibraryPath}");
|
logger.Info($"Using steam library path {vrcLibraryPath}");
|
||||||
_vrcPrefixPath = Path.Join(vrcLibraryPath, $"steamapps/compatdata/{vrchatAppid}/pfx");
|
_vrcPrefixPath = Path.Join(vrcLibraryPath, $"steamapps/compatdata/{vrchatAppid}/pfx");
|
||||||
_vrcAppDataPath = Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat");
|
_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)
|
private static string? GetLibraryWithAppId(string libraryFoldersVdfPath, string appId)
|
||||||
@@ -234,8 +236,12 @@ namespace VRCX
|
|||||||
|
|
||||||
public override bool OpenCrashVrcCrashDumps()
|
public override bool OpenCrashVrcCrashDumps()
|
||||||
{
|
{
|
||||||
// TODO: get path
|
var path = _vrcCrashesPath;
|
||||||
|
if (!Directory.Exists(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
OpenFolderAndSelectItem(path, true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OpenShortcutFolder()
|
public override void OpenShortcutFolder()
|
||||||
@@ -252,22 +258,25 @@ namespace VRCX
|
|||||||
if (!File.Exists(path) && !Directory.Exists(path))
|
if (!File.Exists(path) && !Directory.Exists(path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var directoryPath = isFolder ? path : Path.GetDirectoryName(path);
|
string directoryPath = isFolder ? path : Path.GetDirectoryName(path);
|
||||||
var commandAttempt = new Dictionary<string, string>
|
var commandAttempt = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "nautilus", path },
|
{ "nautilus", $"\"{path}\"" },
|
||||||
{ "nemo", path },
|
{ "nemo", $"\"{path}\"" },
|
||||||
{ "thunar", path },
|
{ "thunar", $"\"{path}\"" },
|
||||||
{ "caja", $"--select \"{path}\"" },
|
{ "caja", $"--select \"{path}\"" },
|
||||||
{ "pcmanfm-qt", directoryPath },
|
{ "pcmanfm-qt", $"\"{directoryPath}\"" },
|
||||||
{ "pcmanfm", directoryPath },
|
{ "pcmanfm", $"\"{directoryPath}\"" },
|
||||||
{ "dolphin", $"--select \"{path}\"" },
|
{ "dolphin", $"--select \"{path}\"" },
|
||||||
{ "konqueror", $"--select \"{path}\"" },
|
{ "konqueror", $"--select \"{path}\"" },
|
||||||
{ "xdg-open", directoryPath }
|
{ "xdg-open", $"\"{directoryPath}\"" }
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var command in commandAttempt)
|
foreach (var command in commandAttempt)
|
||||||
{
|
{
|
||||||
|
if (!IsCommandAvailable(command.Key))
|
||||||
|
continue;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var process = new Process
|
var process = new Process
|
||||||
@@ -276,22 +285,48 @@ namespace VRCX
|
|||||||
{
|
{
|
||||||
FileName = command.Key,
|
FileName = command.Key,
|
||||||
Arguments = command.Value,
|
Arguments = command.Value,
|
||||||
UseShellExecute = true,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true
|
RedirectStandardError = true,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
CreateNoWindow = true,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
process.Start();
|
process.Start();
|
||||||
process.WaitForExit();
|
return; // Assume first successful start is enough
|
||||||
if (process.ExitCode == 0)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
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 = "")
|
public override async Task<string> OpenFolderSelectorDialog(string defaultPath = "")
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
|
|||||||
@@ -1404,10 +1404,10 @@
|
|||||||
<div class="options-container-item" style="margin-top: 15px">
|
<div class="options-container-item" style="margin-top: 15px">
|
||||||
<el-button-group>
|
<el-button-group>
|
||||||
<el-button size="small" icon="el-icon-folder" @click="openVrcxAppDataFolder()"
|
<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()"
|
<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()"
|
<el-button size="small" icon="el-icon-folder" @click="openCrashVrcCrashDumps()"
|
||||||
>Crash Dumps</el-button
|
>Crash Dumps</el-button
|
||||||
|
|||||||
Reference in New Issue
Block a user