From 1f4c7d132e7eec637da7ff43cfe6d3d64ce4dfa2 Mon Sep 17 00:00:00 2001 From: Felipe Borges Date: Tue, 28 Apr 2020 13:28:40 +0200 Subject: [PATCH] info: Add device "Model" row for Lenovo Since we will be shipping Fedora 32 in some Lenovo devices[0], we were asked to add an entry in Settings with a string identifying the laptop model for users to look at while reporting issues[1]. Ideally this logic should live in systemd-hostnamed and be generic enough to handle vendors and their particular ways of exposing this info in userspace. Unfortunately the release is at the door now and that work would require us some more time. Its development is ongoing upstream[2] but won't likely be ready for the F32 that should happen at any moment this week. [0] https://fedoramagazine.org/coming-soon-fedora-on-lenovo-laptops [1] https://teams.fedoraproject.org/project/silverblue/us/127 [2] https://github.com/systemd/systemd/issues/15493 and https://github.com/systemd/systemd/pull/15531 --- gnome-control-center.spec | 8 ++- info-model-for-lenovo.patch | 129 ++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 info-model-for-lenovo.patch diff --git a/gnome-control-center.spec b/gnome-control-center.spec index c0599ab..345586d 100644 --- a/gnome-control-center.spec +++ b/gnome-control-center.spec @@ -10,7 +10,7 @@ Name: gnome-control-center Version: 3.36.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Utilities to configure the GNOME desktop License: GPLv2+ and CC-BY-SA @@ -20,6 +20,9 @@ Source0: https://download.gnome.org/sources/gnome-control-center/3.36/gno # https://bugzilla.gnome.org/show_bug.cgi?id=695691 Patch0: distro-logo.patch +# https://teams.fedoraproject.org/project/silverblue/us/127 +Patch1: info-model-for-lenovo.patch + BuildRequires: chrpath BuildRequires: cups-devel BuildRequires: desktop-file-utils @@ -189,6 +192,9 @@ chrpath --delete $RPM_BUILD_ROOT%{_bindir}/gnome-control-center %dir %{_datadir}/gnome/wm-properties %changelog +* Tue Apr 28 2020 Felipe Borges - 3.36.1-2 +- Add "Model" row info for Lenovo devices + * Fri Mar 27 2020 Kalev Lember - 3.36.1-1 - Update to 3.36.1 diff --git a/info-model-for-lenovo.patch b/info-model-for-lenovo.patch new file mode 100644 index 0000000..f2db219 --- /dev/null +++ b/info-model-for-lenovo.patch @@ -0,0 +1,129 @@ +From cb0c026adad0b3c892d3bb84366ed871d920e97d Mon Sep 17 00:00:00 2001 +From: Felipe Borges +Date: Tue, 28 Apr 2020 12:32:05 +0200 +Subject: [PATCH] info: Add device "Model" row for Lenovo + +Since we will be shipping Fedora 32 in some Lenovo devices[0], we +were asked to add an entry in Settings with a string identifying +the laptop model for users to look at while reporting issues[1]. + +Ideally this logic should live in systemd-hostnamed and be generic +enough to handle vendors and their particular ways of exposing this +info in userspace. Unfortunately the release is at the door now and +that work would require us some more time. Its development is ongoing +upstream[2] but won't likely be ready for the F32 that should happen +at any moment this week. + +[0] https://fedoramagazine.org/coming-soon-fedora-on-lenovo-laptops +[1] https://teams.fedoraproject.org/project/silverblue/us/127 +[2] https://github.com/systemd/systemd/issues/15493 and +https://github.com/systemd/systemd/pull/15531 +--- + panels/info-overview/cc-info-overview-panel.c | 42 +++++++++++++++++++ + .../info-overview/cc-info-overview-panel.ui | 9 ++++ + 2 files changed, 51 insertions(+) + +diff --git a/panels/info-overview/cc-info-overview-panel.c b/panels/info-overview/cc-info-overview-panel.c +index 98c77e97f..1b9916ac7 100644 +--- a/panels/info-overview/cc-info-overview-panel.c ++++ b/panels/info-overview/cc-info-overview-panel.c +@@ -62,6 +62,7 @@ struct _CcInfoOverviewPanel + CcListRow *disk_row; + CcListRow *gnome_version_row; + CcListRow *graphics_row; ++ CcListRow *device_model_row; + GtkListBox *hardware_box; + GtkDialog *hostname_editor; + CcHostnameEntry *hostname_entry; +@@ -417,6 +418,41 @@ get_graphics_hardware_string (void) + return g_strdup (renderer); + } + ++static gchar * ++get_device_model_string (void) ++{ ++ g_autofree char *vendor = NULL; ++ g_autoptr(GError) error = NULL; ++ gchar *model = NULL; ++ ++ if (g_file_get_contents ("/sys/class/dmi/id/sys_vendor", &vendor, NULL, &error)) ++ { ++ if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) ++ return NULL; ++ ++ vendor = g_strchomp (vendor); ++ if ((g_strcmp0 (vendor, "LENOVO") != 0) && (g_strcmp0 (vendor, "lenovo") != 0)) ++ return NULL; ++ ++ if (g_file_get_contents ("/sys/class/dmi/id/product_version", &model, NULL, &error)) ++ { ++ if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) ++ return NULL; ++ ++ model = g_strchomp (model); ++ if (g_strcmp0 (model, "") == 0) { ++ g_free (model); ++ ++ return NULL; ++ } ++ ++ return model; ++ } ++ } ++ ++ return NULL; ++} ++ + static char * + get_os_name (void) + { +@@ -692,6 +728,7 @@ info_overview_panel_setup_overview (CcInfoOverviewPanel *self) + g_autofree char *os_type_text = NULL; + g_autofree char *os_name_text = NULL; + g_autofree gchar *graphics_hardware_string = NULL; ++ g_autofree gchar *device_model_string = NULL; + + if (load_gnome_version (&gnome_version, NULL, NULL)) + cc_list_row_set_secondary_label (self->gnome_version_row, gnome_version); +@@ -717,6 +754,10 @@ info_overview_panel_setup_overview (CcInfoOverviewPanel *self) + + graphics_hardware_string = get_graphics_hardware_string (); + cc_list_row_set_secondary_markup (self->graphics_row, graphics_hardware_string); ++ ++ device_model_string = get_device_model_string (); ++ cc_list_row_set_secondary_markup (self->device_model_row, device_model_string); ++ gtk_widget_set_visible (GTK_WIDGET (self->device_model_row), (device_model_string != NULL)); + } + + static gboolean +@@ -819,6 +860,7 @@ cc_info_overview_panel_class_init (CcInfoOverviewPanelClass *klass) + gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, disk_row); + gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, gnome_version_row); + gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, graphics_row); ++ gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, device_model_row); + gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, hardware_box); + gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, hostname_editor); + gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, hostname_entry); +diff --git a/panels/info-overview/cc-info-overview-panel.ui b/panels/info-overview/cc-info-overview-panel.ui +index de377bb69..e2d18c48b 100644 +--- a/panels/info-overview/cc-info-overview-panel.ui ++++ b/panels/info-overview/cc-info-overview-panel.ui +@@ -68,6 +68,15 @@ + + + ++ ++ ++ ++ False ++ False ++ Model ++ ++ ++ + + + +-- +2.26.1 +