Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ public Process RunInPrefix(string[] args, string workingDirectory = "", IDiction
return RunInPrefix(psi, workingDirectory, environment, redirectOutput, writeLog, wineD3D);
}

public void RunInPrefixAndExit(string[] args, string workingDirectory = "", IDictionary<string, string> environment = null, bool wineD3D = false)
{
var psi = new ProcessStartInfo(Wine64Path);
foreach (var arg in args)
psi.ArgumentList.Add(arg);

psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = false;
psi.RedirectStandardError = false;

var p = PrepareRunInPrefix(psi, workingDirectory, environment, false, wineD3D);
p.Start();

p.WaitForExit();
Environment.Exit(p.ExitCode);
}

private void MergeDictionaries(StringDictionary a, IDictionary<string, string> b)
{
if (b is null)
Expand All @@ -143,10 +160,8 @@ private void MergeDictionaries(StringDictionary a, IDictionary<string, string> b
}
}

private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDictionary<string, string> environment, bool redirectOutput, bool writeLog, bool wineD3D)
private Process PrepareRunInPrefix(ProcessStartInfo psi, string workingDirectory, IDictionary<string, string> environment, bool canGamemode, bool wineD3D)
{
psi.RedirectStandardOutput = redirectOutput;
psi.RedirectStandardError = writeLog;
psi.UseShellExecute = false;
psi.WorkingDirectory = workingDirectory;

Expand Down Expand Up @@ -174,7 +189,7 @@ private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDict
_ => throw new ArgumentOutOfRangeException()
};

if (this.gamemodeOn == true && !ldPreload.Contains("libgamemodeauto.so.0"))
if (canGamemode && this.gamemodeOn == true && !ldPreload.Contains("libgamemodeauto.so.0"))
{
ldPreload = ldPreload.Equals("", StringComparison.OrdinalIgnoreCase) ? "libgamemodeauto.so.0" : ldPreload + ":libgamemodeauto.so.0";
}
Expand All @@ -197,6 +212,17 @@ private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDict

Process helperProcess = new();
helperProcess.StartInfo = psi;

return helperProcess;
}

private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDictionary<string, string> environment, bool redirectOutput, bool writeLog, bool wineD3D)
{
psi.RedirectStandardOutput = redirectOutput;
psi.RedirectStandardError = writeLog;

var helperProcess = PrepareRunInPrefix(psi, workingDirectory, environment, true, wineD3D);

helperProcess.ErrorDataReceived += new DataReceivedEventHandler((_, errLine) =>
{
if (string.IsNullOrEmpty(errLine.Data))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public override void Draw()
Program.CompatibilityTools.RunInPrefix("explorer");
}

if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Strings.OpenWINEExplorerTooltip);
}

if (ImGui.Button(Strings.KillAllWINEProcesses))
{
Program.CompatibilityTools.Kill();
Expand Down
14 changes: 14 additions & 0 deletions src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ private static void Main(string[] args)
SetupLogging(mainArgs);
LoadConfig(storage);

if (args.Length >= 1 && args[0] == "wine")
{
if (args.Length == 1)
{
Console.WriteLine("Usage: xlcore wine taskmgr");
Environment.Exit(1);
return;
}

CreateCompatToolsInstance();
CompatibilityTools.RunInPrefixAndExit([.. args.Skip(1)]);
return;
}

Secrets = GetSecretProvider(storage);

Dictionary<uint, string> apps = [];
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/XIVLauncher.Core/Resources/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ It should be an absolute path to a folder containing wine64 and wineserver binar
<data name="OpenWINEExplorer" xml:space="preserve">
<value>Open WINE explorer (run apps in prefix)</value>
</data>
<data name="OpenWINEExplorerTooltip" xml:space="preserve">
<value>Tip: You can do the same via CLI: &lt;xlcore&gt; wine explorer</value>
</data>
<data name="KillAllWINEProcesses" xml:space="preserve">
<value>Kill all WINE processes</value>
</data>
Expand Down