ncneofetch: hook up ncart logos #1260

pull/1293/head
nick black 4 years ago
parent fe800436ca
commit aab28aadb4
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -12,6 +12,7 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#include <notcurses/direct.h> #include <notcurses/direct.h>
#include <notcurses/notcurses.h> #include <notcurses/notcurses.h>
#include "ncart.h"
typedef struct distro_info { typedef struct distro_info {
const char* name; // must match 'lsb_release -i' const char* name; // must match 'lsb_release -i'
@ -33,6 +34,8 @@ typedef struct fetched_info {
int dimy, dimx; // extracted from xrandr int dimy, dimx; // extracted from xrandr
char* cpu_model; // FIXME don't handle hetero setups yet char* cpu_model; // FIXME don't handle hetero setups yet
int core_count; int core_count;
// if there is no other logo found, fall back to a logo filched from neofetch
const char* neologo; // text with color substitution templates
} fetched_info; } fetched_info;
static void static void
@ -219,6 +222,9 @@ linux_ncneofetch(fetched_info* fi){
} }
} }
if(dinfo->name == NULL){ if(dinfo->name == NULL){
if(fi->logo == NULL){
fi->neologo = get_neofetch_art(distro);
}
dinfo = NULL; dinfo = NULL;
} }
free(distro); free(distro);
@ -286,16 +292,18 @@ freebsd_ncneofetch(fetched_info* fi){
.name = "FreeBSD", .name = "FreeBSD",
.logofile = NULL, // FIXME .logofile = NULL, // FIXME
}; };
fi->neologo = get_neofetch_art("freebsd");
fi->distro_pretty = NULL; fi->distro_pretty = NULL;
return &fbsd; return &fbsd;
} }
static const distro_info* static const distro_info*
dragonfly_ncneofetch(fetched_info* fi){ dragonfly_ncneofetch(fetched_info* fi){
static const distro_info fbsd = { static distro_info fbsd = {
.name = "DragonFly BSD", .name = "DragonFly BSD",
.logofile = NULL, // FIXME .logofile = NULL, // FIXME
}; };
fi->neologo = get_neofetch_art("dragonfly");
fi->distro_pretty = NULL; fi->distro_pretty = NULL;
return &fbsd; return &fbsd;
} }
@ -476,7 +484,8 @@ infoplane(struct ncdirect* ncd, const fetched_info* fi){
struct marshal { struct marshal {
struct ncdirect* nc; struct ncdirect* nc;
const distro_info* dinfo; const distro_info* dinfo;
const char* logo; // read from /etc/os-release, may be NULL const char* logo; // read from /etc/os-release (or builtin), may be NULL
const char* neologo; // fallback from neofetch, text with color sub templates
}; };
static void* static void*
@ -495,6 +504,8 @@ display_thread(void* vmarshal){
return NULL; return NULL;
} }
} }
}else if(m->neologo){
printf(m->neologo);
} }
return NULL; return NULL;
} }
@ -522,6 +533,7 @@ ncneofetch(struct ncdirect* nc){
.nc = nc, .nc = nc,
.dinfo = fi.distro, .dinfo = fi.distro,
.logo = fi.logo, .logo = fi.logo,
.neologo = fi.neologo,
}; };
pthread_t tid; pthread_t tid;
const bool launched = !pthread_create(&tid, NULL, display_thread, &display_marshal); const bool launched = !pthread_create(&tid, NULL, display_thread, &display_marshal);

@ -932,7 +932,7 @@ const struct neofetch_art ncarts[] = {
const char* get_neofetch_art(const char* oskey){ const char* get_neofetch_art(const char* oskey){
for(const struct neofetch_art* nfa = ncarts ; nfa->oskey ; ++nfa){ for(const struct neofetch_art* nfa = ncarts ; nfa->oskey ; ++nfa){
if(strcmp(nfa->oskey, oskey) == 0){ if(strcasecmp(nfa->oskey, oskey) == 0){
return nfa->ncart; return nfa->ncart;
} }
} }

@ -97,7 +97,7 @@ if [ -n "$DONE" ] ; then
echo echo
echo "const char* get_neofetch_art(const char* oskey){" echo "const char* get_neofetch_art(const char* oskey){"
echo " for(const struct neofetch_art* nfa = ncarts ; nfa->oskey ; ++nfa){" echo " for(const struct neofetch_art* nfa = ncarts ; nfa->oskey ; ++nfa){"
echo " if(strcmp(nfa->oskey, oskey) == 0){" echo " if(strcasecmp(nfa->oskey, oskey) == 0){"
echo " return nfa->ncart;" echo " return nfa->ncart;"
echo " }" echo " }"
echo " }" echo " }"

Loading…
Cancel
Save