Get distro logo from os-release
Currently Initial Setup contains a hardcoded mapping from distro ID to logo:
static void
update_distro_logo (GisLanguagePage *page)
{
GisLanguagePagePrivate *priv = gis_language_page_get_instance_private (page);
g_autofree char *id = g_get_os_info (G_OS_INFO_KEY_ID);
gsize i;
static const struct {
const char *id;
const char *logo;
} id_to_logo[] = {
{ "debian", "emblem-debian" },
{ "fedora", "fedora-logo-icon" },
{ "ubuntu", "ubuntu-logo-icon" },
{ "openSUSE Tumbleweed", "opensuse-logo-icon" },
{ "openSUSE Leap", "opensuse-logo-icon" },
{ "SLED", "suse-logo-icon" },
{ "SLES", "suse-logo-icon" },
};
for (i = 0; i < G_N_ELEMENTS (id_to_logo); i++)
{
if (g_strcmp0 (id, id_to_logo[i].id) == 0)
{
g_object_set (priv->logo, "icon-name", id_to_logo[i].logo, NULL);
break;
}
}
}
The os-release spec defines a LOGO
key:
A string, specifying the name of an icon as defined by freedesktop.org Icon Theme Specification. This can be used by graphical applications to display an operating system's or distributor's logo. This field is optional and may not necessarily be implemented on all systems. Examples: "LOGO=fedora-logo", "LOGO=distributor-logo-opensuse"
On a Fedora 33 system (but not an Ubuntu 20.10 system) this field is populated, with the same value as is used above:
>>> GLib.get_os_info("LOGO")
'fedora-logo-icon'
The update_distro_logo
function should first try to look up the LOGO key, and fall back to the current logic. Ideally, one would check each distro in the list. If, like fedora, they include the LOGO
key, they can be removed from the lookup table; if not, like ubuntu, we should ask nicely for this to be added.