From 1c4813d2a2c5c3b7bca349fd4d120f0c04a2585e Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Tue, 20 Aug 2024 12:16:18 -0500 Subject: [PATCH] Set headless mode automatically --- Cmdline/Options.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Cmdline/Options.cs b/Cmdline/Options.cs index 86e459357..53080fb09 100644 --- a/Cmdline/Options.cs +++ b/Cmdline/Options.cs @@ -262,6 +262,18 @@ public virtual int Handle(GameInstanceManager manager, IUser user) log.Info("Verbose logging enabled"); } + // Auto-detect whether IO device is interactive + if (!Headless && (Console.IsInputRedirected || Console.IsOutputRedirected)) + { + log.InfoFormat("Setting headless mode ({0})", + Console.IsInputRedirected + ? Console.IsOutputRedirected + ? "I/O redirected" + : "input redirected" + : "output redirected"); + Headless = true; + } + // Assign user-agent string if user has given us one if (NetUserAgent != null) {