[geary/mjog/800-drop-lsb-release] Application.Client: Use GLib rather than lsb-release for OS info




commit 5b665d70f2c4121b4501251242af9ada15153a2a
Author: Michael Gratton <mike vee net>
Date:   Sat Aug 22 10:45:25 2020 +1000

    Application.Client: Use GLib rather than lsb-release for OS info
    
    Fixes #800

 src/client/application/application-client.vala | 45 +++++---------------------
 1 file changed, 8 insertions(+), 37 deletions(-)
---
diff --git a/src/client/application/application-client.vala b/src/client/application/application-client.vala
index e9648397b..a56206d7e 100644
--- a/src/client/application/application-client.vala
+++ b/src/client/application/application-client.vala
@@ -289,44 +289,15 @@ public class Application.Client : Gtk.Application {
                     _("Unknown")
             });
 
-        // Distro name and version using LSB util
-
-        GLib.SubprocessLauncher launcher = new GLib.SubprocessLauncher(
-            GLib.SubprocessFlags.STDOUT_PIPE |
-            GLib.SubprocessFlags.STDERR_SILENCE
-        );
-        // Reset lang vars so we can guess the strings below
-        launcher.setenv("LANGUAGE", "C", true);
-        launcher.setenv("LANG", "C", true);
-        launcher.setenv("LC_ALL", "C", true);
+        /// Application runtime information label
+        info.add({ _("Distribution name"),
+                    GLib.Environment.get_os_info(GLib.OsInfoKey.NAME)
+            });
 
-        string lsb_output = "";
-        try {
-            GLib.Subprocess lsb_release = launcher.spawnv(
-                { "lsb_release", "-ir" }
-            );
-            lsb_release.communicate_utf8(null, null, out lsb_output, null);
-        } catch (GLib.Error err) {
-            warning("Failed to exec lsb_release: %s", err.message);
-        }
-        if (lsb_output != "") {
-            foreach (string line in lsb_output.split("\n")) {
-                string[] parts = line.split(":", 2);
-                if (parts.length > 1) {
-                    if (parts[0].has_prefix("Distributor ID")) {
-                        /// Application runtime information label
-                        info.add(
-                            { _("Distribution name"), parts[1].strip() }
-                        );
-                    } else if (parts[0].has_prefix("Release")) {
-                        /// Application runtime information label
-                        info.add(
-                            { _("Distribution release"), parts[1].strip() }
-                        );
-                    }
-                }
-            }
-        }
+        /// Application runtime information label
+        info.add({_("Distribution release"),
+                GLib.Environment.get_os_info(GLib.OsInfoKey.VERSION)
+            });
 
         /// Application runtime information label
         info.add({ _("Installation prefix"), INSTALL_PREFIX });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]