From a5d6b0df2ae003297c6c3c22b2f8e5e66f1cceca Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Thu, 28 Oct 2021 14:50:03 +0200 Subject: [PATCH] Log in distro name and version --- AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs index c70afe3..ba2c65a 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs @@ -11,6 +11,7 @@ using System.Globalization; using AM2RLauncher.XML; using log4net; using log4net.Config; +using System.Text.RegularExpressions; namespace AM2RLauncher { @@ -134,11 +135,25 @@ namespace AM2RLauncher log.Info("Mutex check passed. Entering main thread."); log.Info("Current Launcher Version: " + VERSION); log.Info("Current Platform-ID is: " + Platform.ID); + // Log distro and version (if it exists) + if (Platform.IsGtk) + { + string osRelease = ""; + osRelease = File.ReadAllText("/etc/os-release"); + Regex lineRegex = new Regex(".*=.*"); + var results = lineRegex.Matches(osRelease).Cast(); + var version = results.FirstOrDefault(x => x.Value.Contains("VERSION")); + log.Info("Current Distro: " + results.FirstOrDefault(x => x.Value.Contains("NAME")).Value.Substring(5).Replace("\"", "") + + (version == null ? "" : " " + version.Value.Substring(8).Replace("\"",""))); + } // Set the Current Directory to the path the Launcher is located. Fixes some relative path issues. Environment.CurrentDirectory = CrossPlatformOperations.CURRENTPATH; log.Info("Set Launcher CWD to " + Environment.CurrentDirectory); + // But log actual folder location nonetheless + log.Info("Actual Launcher location: " + Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)); + //Set the language to what User wanted or choose local language string userLanguage = CrossPlatformOperations.ReadFromConfig("Language").ToLower(); if (!userLanguage.Equals("default"))