mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-02 13:06:08 +02:00
auto launch platform-specific apps
This commit is contained in:
@@ -23,6 +23,8 @@ namespace VRCX
|
|||||||
public bool KillChildrenOnExit = true;
|
public bool KillChildrenOnExit = true;
|
||||||
public bool RunProcessOnce = true;
|
public bool RunProcessOnce = true;
|
||||||
public readonly string AppShortcutDirectory;
|
public readonly string AppShortcutDirectory;
|
||||||
|
public readonly string AppShortcutDesktop;
|
||||||
|
public readonly string AppShortcutVR;
|
||||||
|
|
||||||
private DateTime startTime = DateTime.Now;
|
private DateTime startTime = DateTime.Now;
|
||||||
private Dictionary<string, HashSet<int>> startedProcesses = new Dictionary<string, HashSet<int>>();
|
private Dictionary<string, HashSet<int>> startedProcesses = new Dictionary<string, HashSet<int>>();
|
||||||
@@ -66,11 +68,12 @@ namespace VRCX
|
|||||||
public AutoAppLaunchManager()
|
public AutoAppLaunchManager()
|
||||||
{
|
{
|
||||||
AppShortcutDirectory = Path.Join(Program.AppDataDirectory, "startup");
|
AppShortcutDirectory = Path.Join(Program.AppDataDirectory, "startup");
|
||||||
|
AppShortcutDesktop = Path.Join(AppShortcutDirectory, "desktop");
|
||||||
|
AppShortcutVR = Path.Join(AppShortcutDirectory, "vr");
|
||||||
|
|
||||||
if (!Directory.Exists(AppShortcutDirectory))
|
Directory.CreateDirectory(AppShortcutDirectory);
|
||||||
{
|
Directory.CreateDirectory(AppShortcutDesktop);
|
||||||
Directory.CreateDirectory(AppShortcutDirectory);
|
Directory.CreateDirectory(AppShortcutVR);
|
||||||
}
|
|
||||||
|
|
||||||
ProcessMonitor.Instance.ProcessStarted += OnProcessStarted;
|
ProcessMonitor.Instance.ProcessStarted += OnProcessStarted;
|
||||||
ProcessMonitor.Instance.ProcessExited += OnProcessExited;
|
ProcessMonitor.Instance.ProcessExited += OnProcessExited;
|
||||||
@@ -111,6 +114,7 @@ namespace VRCX
|
|||||||
UpdateChildProcesses();
|
UpdateChildProcesses();
|
||||||
|
|
||||||
var shortcutFiles = FindShortcutFiles(AppShortcutDirectory);
|
var shortcutFiles = FindShortcutFiles(AppShortcutDirectory);
|
||||||
|
shortcutFiles.AddRange(FindShortcutFiles(Program.AppApiInstance.IsSteamVRRunning() ? AppShortcutVR : AppShortcutDesktop));
|
||||||
foreach (var file in shortcutFiles)
|
foreach (var file in shortcutFiles)
|
||||||
{
|
{
|
||||||
if (RunProcessOnce && IsProcessRunning(file))
|
if (RunProcessOnce && IsProcessRunning(file))
|
||||||
@@ -122,7 +126,7 @@ namespace VRCX
|
|||||||
StartChildProcess(file);
|
StartChildProcess(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shortcutFiles.Length == 0)
|
if (shortcutFiles.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
timerTicks = 0;
|
timerTicks = 0;
|
||||||
@@ -328,7 +332,7 @@ namespace VRCX
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="folderPath">The folder path.</param>
|
/// <param name="folderPath">The folder path.</param>
|
||||||
/// <returns>An array of shortcut paths. If none, then empty.</returns>
|
/// <returns>An array of shortcut paths. If none, then empty.</returns>
|
||||||
private static string[] FindShortcutFiles(string folderPath)
|
private static List<string> FindShortcutFiles(string folderPath)
|
||||||
{
|
{
|
||||||
DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);
|
DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);
|
||||||
FileInfo[] files = directoryInfo.GetFiles();
|
FileInfo[] files = directoryInfo.GetFiles();
|
||||||
@@ -342,7 +346,7 @@ namespace VRCX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret.ToArray();
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -664,7 +664,7 @@
|
|||||||
"app_launcher": {
|
"app_launcher": {
|
||||||
"header": "App Launcher",
|
"header": "App Launcher",
|
||||||
"folder": "Auto-Launch Folder",
|
"folder": "Auto-Launch Folder",
|
||||||
"folder_tooltip": "To auto-launch apps with VRChat, place shortcuts in this folder.",
|
"folder_tooltip": "To auto-launch apps with VRChat, place shortcuts inside this folder, alteratively use the platform-specific subfolders",
|
||||||
"enable": "Enable",
|
"enable": "Enable",
|
||||||
"auto_close": "Auto close apps",
|
"auto_close": "Auto close apps",
|
||||||
"run_process_once": "Open single instance of app"
|
"run_process_once": "Open single instance of app"
|
||||||
|
|||||||
Reference in New Issue
Block a user