diff options
| author | Burt P <pburt0@gmail.com> | 2019-06-29 13:16:35 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-06-29 17:58:52 -0700 | 
| commit | c57824328430f63b487fb302a71a100a6a7ac30d (patch) | |
| tree | b8a3a796e5bf1e2744a7b557cfde903cd1d384e7 /modules | |
| parent | 8167a6f66527193f770bc8cb347c8c510496ae7f (diff) | |
Computer Summary RAM tweak
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/computer.c | 22 | 
1 files changed, 19 insertions, 3 deletions
| diff --git a/modules/computer.c b/modules/computer.c index bf2ad16e..e080f276 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -819,6 +819,8 @@ gchar *get_audio_cards(void)      return computer_get_alsacards(computer);  } +/* the returned string must stay in kB as it is used + * elsewhere with that expectation */  gchar *get_memory_total(void)  {      scan_memory_usage(FALSE); @@ -829,16 +831,30 @@ gchar *memory_devices_get_system_memory_str(); /* in dmi_memory.c */  gchar *memory_devices_get_system_memory_types_str();  gchar *get_memory_desc(void)  { +    scan_memory_usage(FALSE); +    gchar *avail = moreinfo_lookup("DEV:MemTotal"); +    double k = avail ? (double)strtol(avail, NULL, 10) : 0; +    g_free(avail); +    avail = NULL; +    if (k) { +        const char *fmt = _(/*/ <value> <unit> "usable memory" */ "%0.1f %s available to Linux"); +        if (k > (2048 * 1024)) +            avail = g_strdup_printf(fmt, k / (1024*1024), _("GiB") ); +        else if (k > 2048) +            avail = g_strdup_printf(fmt, k / 1024, _("MiB") ); +        else +            avail = g_strdup_printf(fmt, k, _("KiB") ); +    }      gchar *mem = memory_devices_get_system_memory_str();      if (mem) {          gchar *types = memory_devices_get_system_memory_types_str(); -        gchar *ret = g_strdup_printf("%s\n%s", mem, types); +        gchar *ret = g_strdup_printf("%s %s\n%s", mem, types, avail ? avail : ""); +        g_free(avail);          g_free(mem);          g_free(types);          return ret;      } -    scan_memory_usage(FALSE); -    return moreinfo_lookup ("DEV:MemTotal"); +    return avail;  }  ShellModuleMethod *hi_exported_methods(void) | 
