From 39db9aca78bc69846fcad166190d20e24a55c964 Mon Sep 17 00:00:00 2001 From: Burt P Date: Thu, 26 Dec 2019 02:27:07 -0600 Subject: computer/display: add notes for wanted extern utils Signed-off-by: Burt P --- modules/computer.c | 71 ++++++++++++++++++++++++++++++++++++-------- modules/devices/dmi_memory.c | 23 +++++++------- 2 files changed, 70 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/computer.c b/modules/computer.c index 0123ef26..295a3ed4 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -76,22 +76,40 @@ void scan_env_var(gboolean reload); void scan_dev(gboolean reload); #endif /* GLIB_CHECK_VERSION(2,14,0) */ +enum { + ENTRY_SUMMARY, + ENTRY_OS, + ENTRY_SECURITY, + ENTRY_KMOD, + ENTRY_BOOTS, + ENTRY_LANGUAGES, + ENTRY_MEMORY_USAGE, + ENTRY_FS, + ENTRY_DISPLAY, + ENTRY_ENV, + ENTRY_DEVEL, + ENTRY_USERS, + ENTRY_GROUPS +}; + static ModuleEntry entries[] = { - {N_("Summary"), "summary.png", callback_summary, scan_summary, MODULE_FLAG_NONE}, - {N_("Operating System"), "os.png", callback_os, scan_os, MODULE_FLAG_NONE}, - {N_("Security"), "security.png", callback_security, scan_security, MODULE_FLAG_NONE}, - {N_("Kernel Modules"), "module.png", callback_modules, scan_modules, MODULE_FLAG_NONE}, - {N_("Boots"), "boot.png", callback_boots, scan_boots, MODULE_FLAG_NONE}, - {N_("Languages"), "language.png", callback_locales, scan_locales, MODULE_FLAG_NONE}, - {N_("Memory Usage"), "memory.png", callback_memory_usage, scan_memory_usage, MODULE_FLAG_NONE}, - {N_("Filesystems"), "dev_removable.png", callback_fs, scan_fs, MODULE_FLAG_NONE}, - {N_("Display"), "monitor.png", callback_display, scan_display, MODULE_FLAG_NONE}, - {N_("Environment Variables"), "environment.png", callback_env_var, scan_env_var, MODULE_FLAG_NONE}, + [ENTRY_SUMMARY] = {N_("Summary"), "summary.png", callback_summary, scan_summary, MODULE_FLAG_NONE}, + [ENTRY_OS] = {N_("Operating System"), "os.png", callback_os, scan_os, MODULE_FLAG_NONE}, + [ENTRY_SECURITY] = {N_("Security"), "security.png", callback_security, scan_security, MODULE_FLAG_NONE}, + [ENTRY_KMOD] = {N_("Kernel Modules"), "module.png", callback_modules, scan_modules, MODULE_FLAG_NONE}, + [ENTRY_BOOTS] = {N_("Boots"), "boot.png", callback_boots, scan_boots, MODULE_FLAG_NONE}, + [ENTRY_LANGUAGES] = {N_("Languages"), "language.png", callback_locales, scan_locales, MODULE_FLAG_NONE}, + [ENTRY_MEMORY_USAGE] = {N_("Memory Usage"), "memory.png", callback_memory_usage, scan_memory_usage, MODULE_FLAG_NONE}, + [ENTRY_FS] = {N_("Filesystems"), "dev_removable.png", callback_fs, scan_fs, MODULE_FLAG_NONE}, + [ENTRY_DISPLAY] = {N_("Display"), "monitor.png", callback_display, scan_display, MODULE_FLAG_NONE}, + [ENTRY_ENV] = {N_("Environment Variables"), "environment.png", callback_env_var, scan_env_var, MODULE_FLAG_NONE}, #if GLIB_CHECK_VERSION(2,14,0) - {N_("Development"), "devel.png", callback_dev, scan_dev, MODULE_FLAG_NONE}, + [ENTRY_DEVEL] = {N_("Development"), "devel.png", callback_dev, scan_dev, MODULE_FLAG_NONE}, +#else + [ENTRY_DEVEL] = {N_("Development"), "devel.png", callback_dev, scan_dev, MODULE_FLAG_HIDE}, #endif /* GLIB_CHECK_VERSION(2,14,0) */ - {N_("Users"), "users.png", callback_users, scan_users, MODULE_FLAG_NONE}, - {N_("Groups"), "users.png", callback_groups, scan_groups, MODULE_FLAG_NONE}, + [ENTRY_USERS] = {N_("Users"), "users.png", callback_users, scan_users, MODULE_FLAG_NONE}, + [ENTRY_GROUPS] = {N_("Groups"), "users.png", callback_groups, scan_groups, MODULE_FLAG_NONE}, {NULL}, }; @@ -1055,3 +1073,30 @@ ModuleAbout *hi_module_get_about(void) return ma; } +static const gchar *hinote_kmod() { + static gchar note[note_max_len] = ""; + gboolean ok = TRUE; + *note = 0; /* clear */ + ok &= note_require_tool("lsmod", note, _("lsmod is required.")); + return ok ? NULL : g_strstrip(note); /* remove last \n */ +} + +static const gchar *hinote_display() { + static gchar note[note_max_len] = ""; + gboolean ok = TRUE; + *note = 0; /* clear */ + ok &= note_require_tool("xrandr", note, _("X.org's xrandr utility provides additional details when available.")); + ok &= note_require_tool("glxinfo", note, _("Mesa's glxinfo utility is required for OpenGL information.")); + return ok ? NULL : g_strstrip(note); /* remove last \n */ +} + +const gchar *hi_note_func(gint entry) +{ + if (entry == ENTRY_KMOD) { + return hinote_kmod(); + } + else if (entry == ENTRY_DISPLAY) { + return hinote_display(); + } + return NULL; +} diff --git a/modules/devices/dmi_memory.c b/modules/devices/dmi_memory.c index 4bb7246e..423b7525 100644 --- a/modules/devices/dmi_memory.c +++ b/modules/devices/dmi_memory.c @@ -977,10 +977,9 @@ gchar *memory_devices_get_system_memory_str() { return ret; } -static gchar *note_state = NULL; +static gchar note_state[note_max_len] = ""; gboolean memory_devices_hinote(const char **msg) { - gchar *want_dmi = _(" dmidecode utility available"); gchar *want_root = _(" ... and HardInfo running with superuser privileges"); gchar *want_eeprom = _(" eeprom module loaded (for SDR, DDR, DDR2, DDR3)"); @@ -991,15 +990,17 @@ gboolean memory_devices_hinote(const char **msg) { gboolean has_eeprom = g_file_test("/sys/bus/i2c/drivers/eeprom", G_FILE_TEST_IS_DIR); gboolean has_ee1004 = g_file_test("/sys/bus/i2c/drivers/ee1004", G_FILE_TEST_IS_DIR); - char *bullet_yes = "\u2713"; - char *bullet_no = "\u2022 "; - - g_free(note_state); - note_state = g_strdup(_("Memory information requires one or both of the following:")); - note_state = appfnl(note_state, "1. %s%s", has_dmi ? bullet_yes : bullet_no, want_dmi); - note_state = appfnl(note_state, " %s%s", has_root ? bullet_yes : bullet_no, want_root); - note_state = appfnl(note_state, "2. %s%s", has_eeprom ? bullet_yes : bullet_no, want_eeprom); - note_state = appfnl(note_state, " %s%s", has_ee1004 ? bullet_yes : bullet_no, want_ee1004); + *note_state = 0; /* clear */ + note_printf(note_state, "%s\n", _("Memory information requires one or both of the following:")); + note_print(note_state, "1. "); + note_cond_bullet(has_dmi, note_state, want_dmi); + note_print(note_state, " "); + note_cond_bullet(has_root, note_state, want_root); + note_print(note_state, "2. "); + note_cond_bullet(has_eeprom, note_state, want_eeprom); + note_print(note_state, " "); + note_cond_bullet(has_ee1004, note_state, want_ee1004); + g_strstrip(note_state); /* remove last \n */ gboolean ddr3_ee1004 = ((dmi_ram_types & (1<