From 355021de56866a77c1a91d7b438966a351893385 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 18 Jun 2020 01:34:07 -0400 Subject: [PATCH] ncneofetch: print ram/processes #550 --- include/notcurses/notcurses.h | 1 + src/fetch/main.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 4fed05763..92856a343 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -692,6 +692,7 @@ API void cell_release(struct ncplane* n, cell* c); #define NCSTYLE_INVIS 0x00020000ul #define NCSTYLE_PROTECT 0x00010000ul #define NCSTYLE_ITALIC 0x01000000ul +#define NCSTYLE_NONE 0 // Set the specified style bits for the cell 'c', whether they're actively // supported or not. diff --git a/src/fetch/main.c b/src/fetch/main.c index 602bb4d0c..b51d255be 100644 --- a/src/fetch/main.c +++ b/src/fetch/main.c @@ -252,9 +252,17 @@ infoplane(struct notcurses* nc, const fetched_info* fi){ return -1; } ncplane_set_fg_rgb(infop, 0xd0, 0xd0, 0xd0); + ncplane_set_attr(infop, NCSTYLE_UNDERLINE); ncplane_printf_aligned(infop, 1, NCALIGN_LEFT, " %s %s", fi->kernel, fi->kernver); ncplane_printf_aligned(infop, 1, NCALIGN_RIGHT, "%s %s ", fi->distro->name, fi->distro_release); + ncplane_set_attr(infop, NCSTYLE_NONE); + struct sysinfo sinfo; + sysinfo(&sinfo); + unsigned long totalmib = sinfo.totalram / (1024 * 1024); + unsigned long usedmib = totalmib - (sinfo.freeram / 1024 / 1024); + ncplane_printf_aligned(infop, 2, NCALIGN_LEFT, " RAM: %lu/%lu\n", usedmib, totalmib); + ncplane_printf_aligned(infop, 2, NCALIGN_RIGHT, "Processes: %hu ", sinfo.procs); cell ul = CELL_TRIVIAL_INITIALIZER; cell ur = CELL_TRIVIAL_INITIALIZER; cell ll = CELL_TRIVIAL_INITIALIZER; cell lr = CELL_TRIVIAL_INITIALIZER; cell hl = CELL_TRIVIAL_INITIALIZER; cell vl = CELL_TRIVIAL_INITIALIZER; @@ -286,8 +294,6 @@ infoplane(struct notcurses* nc, const fetched_info* fi){ channels_set_fg_rgb(&channels, 0, 0, 0); channels_set_bg_rgb(&channels, 0x50, 0x50, 0x50); ncplane_set_base(infop, " ", 0, channels); - struct sysinfo sinfo; - sysinfo(&sinfo); return 0; }