Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make systemd optional #746

Merged
merged 5 commits into from
Mar 11, 2024
Merged

Conversation

oz123
Copy link
Contributor

@oz123 oz123 commented Mar 3, 2024

There is not much of direct systemd usage in the system-info plugin. This patch suggestion enables building this plugin on system like alpine, voidlinux or gentoo with openrc.

I apologize in advance if this seems sloppy. I am not very knowledgeable with autotools (also, this patch excludes meson).

Suggestions on how to improve the patch are most welcome.

@oz123
Copy link
Contributor Author

oz123 commented Mar 3, 2024

This patch compiles, but system host name is still missing:

image

Suggestions on how to fix will be most welcome.

@zhuyaliang
Copy link
Member

zhuyaliang commented Mar 4, 2024

Code update required

diff --git a/capplets/system-info/mate-system-info.c b/capplets/system-info/mate-system-info.c
index 3638067..8f7325f 100644
--- a/capplets/system-info/mate-system-info.c
+++ b/capplets/system-info/mate-system-info.c
@@ -130,21 +130,25 @@ mate_system_info_row_fill (GtkWidget  *row,
 static void
 mate_system_info_set_row (MateSystemInfo *info)
 {
+#ifdef HAVE_SYSTEMD
     mate_system_info_row_fill (info->hostname_row, _("Device Name"), FALSE);
     mate_system_info_row_fill (info->hardware_model_row, _("Hardware Model"), TRUE);
+    mate_system_info_row_fill (info->virtualization_row, _("Virtualization"), TRUE);
+#endif
     mate_system_info_row_fill (info->memory_row, _("Memory"), TRUE);
     mate_system_info_row_fill (info->processor_row, _("Processor"), TRUE);
     mate_system_info_row_fill (info->graphics_row, _("Graphics"), TRUE);
     mate_system_info_row_fill (info->disk_row, _("Disk Capacity"), FALSE);
     mate_system_info_row_fill (info->kernel_row, _("Kernel Version"), FALSE);
-    mate_system_info_row_fill (info->virtualization_row, _("Virtualization"), TRUE);
     mate_system_info_row_fill (info->windowing_system_row, _("Windowing System"), TRUE);
     mate_system_info_row_fill (info->mate_version_row, _("MATE Version"), TRUE);
     mate_system_info_row_fill (info->os_name_row, _("OS Name"), TRUE);
     mate_system_info_row_fill (info->os_type_row, _("OS Type"), TRUE);
 
     gtk_widget_show (info->logo_image);
+#ifdef HAVE_SYSTEMD
     gtk_widget_show_all (info->hostname_row);
+#endif
     gtk_widget_show_all (info->memory_row);
     gtk_widget_show_all (info->processor_row);
     gtk_widget_show_all (info->graphics_row);
@@ -614,8 +618,11 @@ void
 mate_system_info_setup (MateSystemInfo *info)
 {
     g_autofree char *logo_name = NULL;
+#ifdef HAVE_SYSTEMD
     g_autofree char *hostname_text = NULL;
     g_autofree char *hw_model_text = NULL;
+    g_autofree char *virt_text = NULL;
+#endif
     g_autofree char *memory_text = NULL;
     g_autofree char *cpu_text = NULL;
     g_autofree char *os_type_text = NULL;
@@ -623,7 +630,6 @@ mate_system_info_setup (MateSystemInfo *info)
     g_autofree char *disk_text = NULL;
     g_autofree char *kernel_text = NULL;
     g_autofree char *windowing_system_text = NULL;
-    g_autofree char *virt_text = NULL;
     g_autofree char *de_text = NULL;
     g_autofree char *graphics_hardware_string = NULL;
 
@@ -634,6 +640,7 @@ mate_system_info_setup (MateSystemInfo *info)
     gtk_image_set_from_icon_name (GTK_IMAGE (info->logo_image), logo_name, GTK_ICON_SIZE_INVALID);
     gtk_image_set_pixel_size (GTK_IMAGE (info->logo_image), 128);
 
+#ifdef HAVE_SYSTEMD
     hostname_text = get_system_hostname ();
     label = g_object_get_data (G_OBJECT (info->hostname_row), "labelvalue");
     set_lable_style (label, "gray", 12, hostname_text, FALSE);
@@ -645,7 +652,7 @@ mate_system_info_setup (MateSystemInfo *info)
         label = g_object_get_data (G_OBJECT (info->hardware_model_row), "labelvalue");
         set_lable_style (label, "gray", 12, hw_model_text, FALSE);
     }
+#endif
     glibtop_get_mem (&mem);
     memory_text = g_format_size_full (mem.total, G_FORMAT_SIZE_IEC_UNITS);
     label = g_object_get_data (G_OBJECT (info->memory_row), "labelvalue");
@@ -704,20 +711,21 @@ mate_system_info_class_init (MateSystemInfoClass *klass)
 
     widget_class->destroy = mate_system_info_destroy;
     gtk_widget_class_set_template_from_resource (widget_class, "/org/mate/control-center/system-info/mate-system-info.ui");
-
+#ifdef HAVE_SYSTEMD
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hostname_row);
+    gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hardware_model_row);
+    gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, virtualization_row);
+#endif
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hardware_box);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, disk_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, mate_version_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, graphics_row);
-    gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hardware_model_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, memory_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_box);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, logo_image);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_name_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_type_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, processor_row);
-    gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, virtualization_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, kernel_row);
     gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, windowing_system_row);
 }

@zhuyaliang
Copy link
Member

Fix #744 #738

There is not much of direct systemd usage in the system-info plugin.
This patch suggestion enables building this plugin on system like
alpine, voidlinux or gentoo with openrc.

Signed-off-by: Oz Tiram <[email protected]>
@oz123 oz123 marked this pull request as ready for review March 4, 2024 06:50
capplets/system-info/mate-system-info.c Outdated Show resolved Hide resolved
capplets/system-info/mate-system-info.c Outdated Show resolved Hide resolved
capplets/system-info/mate-system-info.c Show resolved Hide resolved
capplets/system-info/mate-system-info.c Show resolved Hide resolved
@oz123
Copy link
Contributor Author

oz123 commented Mar 4, 2024

@zhuyaliang thank you for your suggestions. I have disabled some of the definitions, but left the hostname row.

This is how the applet now looks on my system with the latest patch:
image

Copy link
Member

@zhuyaliang zhuyaliang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work,Compile and run well。
I will add systemd support for meson in the next commit

Copy link
Member

@raveit65 raveit65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be compile as default with systemd without using a configure flag when systemd-devel is in buildroot.
With fedora 38 build server:

DEBUG: systemd-rpm-macros-253.15-2.fc38.noarch 1705943792 10329 e9510145d6c474e8e57af8a6d2cea362 installed
DEBUG: systemd-devel-253.15-2.fc38.x86_64 1705943804 500482 6fd0c7ccd450f2731c747c7e2d5c4053 installed
...
....
...
Ayatana AppIndicator (preferred)   no
Ubuntu AppIndicator (legacy)       yes
Systemd:                           no

Accountsservice:           yes
Native Language support:   yes

BuildRequires: systemd-devel is in RPM spec file.

@raveit65
Copy link
Member

raveit65 commented Mar 5, 2024

Also --enable-systemd=auto doesn't build with systemd support.
I have to use --enable-systemd=yes to build with systemd support.
That's not acceptable nowadays as most distros are using systemd.

@raveit65
Copy link
Member

raveit65 commented Mar 5, 2024

You can take a look at mate-system-monitor repository.
https://github.com/mate-desktop/mate-system-monitor/blob/master/configure.ac
There it works without using a configure flag, only systemd-devel needs to be in buildroot.

@oz123
Copy link
Contributor Author

oz123 commented Mar 6, 2024

@raveit65 I updated my PR as requested.

Signed-off-by: Oz Tiram <[email protected]>
@oz123 oz123 requested a review from raveit65 March 6, 2024 22:18
@raveit65 raveit65 removed their request for review March 6, 2024 22:23
@oz123
Copy link
Contributor Author

oz123 commented Mar 11, 2024

@raveit65 is there anything else that needs to be done to get this merged?

@raveit65
Copy link
Member

I am not an active maintainer any more.
@lukefromdc

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to go, with systemd support building on my setup by default without explicitly having to enable it

@lukefromdc lukefromdc merged commit d7f3c62 into mate-desktop:master Mar 11, 2024
1 check passed
@oz123
Copy link
Contributor Author

oz123 commented Mar 11, 2024

Thank you for merging this, on behalf of all BSD\Alpine\Gentoo\Void linux and others I might forget.

@tbzatek
Copy link

tbzatek commented Mar 18, 2024

Thank you for merging this, on behalf of all BSD\Alpine\Gentoo\Void linux and others I might forget.

Second that (Gentoo user here), thanks for staying independent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants