diff options
author | Leandro Pereira <leandro@hardinfo.org> | 2020-05-03 10:11:13 -0700 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2020-05-03 10:11:13 -0700 |
commit | 0867b5c6b8ee0e8b1fb9a969f13975eab6ab0fc9 (patch) | |
tree | f91a78da7c4b44a3451c3ad484dfcd80aedb1022 /modules/computer | |
parent | 142244445116202f3ae99e64a271e7e53bfc7a54 (diff) |
Show distro code name, if present
Diffstat (limited to 'modules/computer')
-rw-r--r-- | modules/computer/os.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/computer/os.c b/modules/computer/os.c index 32e4e8cd..14f61e06 100644 --- a/modules/computer/os.c +++ b/modules/computer/os.c @@ -353,6 +353,7 @@ parse_os_release(void) { gchar *pretty_name = NULL; gchar *id = NULL; + gchar *codename = NULL; gchar **split, *contents, **line; if (!g_file_get_contents("/usr/lib/os-release", &contents, NULL, NULL)) @@ -365,6 +366,8 @@ parse_os_release(void) for (line = split; *line; line++) { if (!strncmp(*line, "ID=", sizeof("ID=") - 1)) { id = g_strdup(*line + strlen("ID=")); + } else if (!strncmp(*line, "CODENAME=", sizeof("CODENAME=") - 1)) { + codename = g_strdup(*line + strlen("CODENAME=")); } else if (!strncmp(*line, "PRETTY_NAME=", sizeof("PRETTY_NAME=") - 1)) { pretty_name = g_strdup(*line + strlen("PRETTY_NAME=\"")); @@ -375,7 +378,7 @@ parse_os_release(void) g_strfreev(split); if (pretty_name) - return (Distro) { .distro = pretty_name, .codename = id }; + return (Distro) { .distro = pretty_name, .codename = codename, .id = id }; g_free(id); return (Distro) {}; @@ -386,6 +389,7 @@ parse_lsb_release(void) { gchar *pretty_name = NULL; gchar *id = NULL; + gchar *codename = NULL; gchar **split, *contents, **line; if (!hardinfo_spawn_command_line_sync("/usr/bin/lsb_release -di", &contents, NULL, NULL, NULL)) @@ -398,6 +402,8 @@ parse_lsb_release(void) for (line = split; *line; line++) { if (!strncmp(*line, "Distributor ID:\t", sizeof("Distributor ID:\t") - 1)) { id = g_utf8_strdown(*line + strlen("Distributor ID:\t"), -1); + } else if (!strncmp(*line, "Codename:\t", sizeof("Codename:\t") - 1)) { + codename = g_utf8_strdown(*line + strlen("Codename:\t"), -1); } else if (!strncmp(*line, "Description:\t", sizeof("Description:\t") - 1)) { pretty_name = g_strdup(*line + strlen("Description:\t")); } @@ -406,7 +412,7 @@ parse_lsb_release(void) g_strfreev(split); if (pretty_name) - return (Distro) { .distro = pretty_name, .codename = id }; + return (Distro) { .distro = pretty_name, .codename = codename, .id = id }; g_free(id); return (Distro) {}; @@ -510,6 +516,7 @@ computer_get_os(void) Distro distro = detect_distro(); os->distro = g_strstrip(distro.distro); + os->distroid = distro.id; os->distrocode = distro.codename; /* Kernel and hostname info */ |