tighten up ncneofetch a bit

Use 74 columns for infoplane, handling longer model names.
Match /etc/os-release fields whether delimited by tabs or
spaces. Properly extract only the names from /etc/os-release.
pull/1293/head
nick black 4 years ago
parent c4f61c528d
commit 6077cbde5c
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -82,22 +82,30 @@ fetch_cpu_info(fetched_info* fi){
}
char buf[BUFSIZ];
while(fgets(buf, sizeof(buf), cpuinfo)){
#define CORE "core id\t"
#define CORE "core id"
// model name doesn't appear on all architectures, so fall back to vendor_id
#define TAG "model name\t"
#define VEND "vendor_id\t"
#define TAG "model name"
#define VEND "vendor_id"
if(strncmp(buf, TAG, strlen(TAG)) == 0){
// model name trumps vendor_id
free(fi->cpu_model);
char* nl = strchr(buf + strlen(TAG), '\n');
*nl = '\0';
fi->cpu_model = strdup(buf + strlen(TAG));
char* start = strchr(buf + strlen(TAG), ':');
if(start){
++start;
char* nl = strchr(start, '\n');
*nl = '\0';
fi->cpu_model = strdup(start);
}
}else if(strncmp(buf, VEND, strlen(VEND)) == 0){
// vendor_id ought only be used in the absence of model name
if(fi->cpu_model == NULL){
char* nl = strchr(buf + strlen(VEND), '\n');
*nl = '\0';
fi->cpu_model = strdup(buf + strlen(VEND));
char* start = strchr(buf + strlen(VEND), ':');
if(start){
++start;
char* nl = strchr(start, '\n');
*nl = '\0';
fi->cpu_model = strdup(start);
}
}
}else if(strncmp(buf, CORE, strlen(CORE)) == 0){
++fi->core_count;
@ -378,7 +386,7 @@ place_infoplane(struct ncdirect* ncd, int planeheight){
static int
infoplane_notcurses(struct notcurses* nc, const fetched_info* fi, int planeheight){
const int planewidth = 60;
const int planewidth = 72;
int dimy;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, NULL);
struct ncplane_options nopts = {

Loading…
Cancel
Save