diff options
-rw-r--r-- | includes/computer.h | 2 | ||||
-rw-r--r-- | modules/computer.c | 11 | ||||
-rw-r--r-- | modules/computer/os.c | 11 |
3 files changed, 19 insertions, 5 deletions
diff --git a/includes/computer.h b/includes/computer.h index 25da8e27..b537f7b1 100644 --- a/includes/computer.h +++ b/includes/computer.h @@ -97,6 +97,7 @@ struct _OperatingSystem { gchar *kcmdline; gchar *libc; gchar *distrocode; + gchar *distroid; gchar *distro; gchar *hostname; gchar *language; @@ -123,6 +124,7 @@ struct _MemoryInfo { struct _Distro { gchar *distro; gchar *codename; + gchar *id; }; #define get_str(field_name,ptr) \ diff --git a/modules/computer.c b/modules/computer.c index 6cd778e8..49a1511f 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -579,13 +579,18 @@ gchar *callback_os(void) { struct Info *info = info_new(); gchar *distro_icon; + gchar *distro; info_set_view_type(info, SHELL_VIEW_DETAIL); - distro_icon = computer->os->distrocode + distro_icon = computer->os->distroid ? idle_free(g_strdup_printf("distros/%s.svg", - computer->os->distrocode)) + computer->os->distroid)) : NULL; + distro = computer->os->distrocode + ? idle_free(g_strdup_printf("%s (%s)", + computer->os->distro, computer->os->distrocode)) + : computer->os->distro; struct InfoGroup *version_group = info_add_group( @@ -593,7 +598,7 @@ gchar *callback_os(void) info_field(_("Command Line"), computer->os->kcmdline ?: _("Unknown")), info_field(_("Version"), computer->os->kernel_version), info_field(_("C Library"), computer->os->libc), - info_field(_("Distribution"), computer->os->distro, + info_field(_("Distribution"), distro, .value_has_vendor = TRUE, .icon = distro_icon), info_field_last()); 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 */ |