From d02a6323bb0d8f45c11a737094574324b763f8dd Mon Sep 17 00:00:00 2001 From: Jason Goulet-Lipman Date: Fri, 4 Jun 2021 09:56:34 -0400 Subject: [PATCH] fixed bugs and added distros --- config.h | 24 ++++++++++++++++++++---- logos/arch2.h | 21 --------------------- logos/arch3.h | 22 ---------------------- logos/artix.h | 23 +++++++++++++++++++++++ logos/debian.h | 21 +++++++++++++++++++++ logos/fedora.h | 21 +++++++++++++++++++++ logos/manjaro.h | 17 +++++++++++++++++ logos/ubuntu.h | 22 ++++++++++++++++++++++ paleofetch.c | 22 +++++++++++----------- 9 files changed, 135 insertions(+), 58 deletions(-) delete mode 100644 logos/arch2.h delete mode 100644 logos/arch3.h create mode 100644 logos/artix.h create mode 100644 logos/debian.h create mode 100644 logos/fedora.h create mode 100644 logos/manjaro.h create mode 100644 logos/ubuntu.h diff --git a/config.h b/config.h index 39c621c..87a4579 100644 --- a/config.h +++ b/config.h @@ -1,9 +1,24 @@ #include "logos/arch.h" -#define COLOR "\e[1;36m" +//define colors +#define BLACK "\e[1;30m" +#define RED "\e[1;31m" +#define GREEN "\e[1;32m" +#define YELLOW "\e[1;33m" +#define BLUE "\e[1;34m" +#define PURPLE "\e[1;35m" +#define CYAN "\e[1;36m" +#define WHITE "\e[1;37m" + + +//define display colors +#define COLOR BLUE +#define LOGOCOLOR CYAN +#define TITLECOLOR BLUE #define CONFIG \ { \ /* name function cached */\ + SPACER \ { "", get_title, false }, \ { "", get_bar, false }, \ { "OS: ", get_os, true }, \ @@ -11,14 +26,12 @@ { "Kernel: ", get_kernel, true }, \ { "Uptime: ", get_uptime, false }, \ { "Battery: ", get_battery_percentage, false }, \ - SPACER \ { "Packages: ", get_packages_pacman, false }, \ { "Shell: ", get_shell, false }, \ { "Resolution: ", get_resolution, false }, \ { "Terminal: ", get_terminal, false }, \ - SPACER \ { "CPU: ", get_cpu, true }, \ - { "GPU: ", get_gpu1, true }, \ + { "GPU: ", get_gpu1, true }, \ { "Memory: ", get_memory, false }, \ SPACER \ { "", get_colors1, false }, \ @@ -40,4 +53,7 @@ #define GPU_CONFIG \ { \ REMOVE("Corporation"), \ + REMOVE("Controller"), \ + REMOVE("Graphics"), \ + REMOVE("Integrated"), \ } diff --git a/logos/arch2.h b/logos/arch2.h deleted file mode 100644 index e06cfe2..0000000 --- a/logos/arch2.h +++ /dev/null @@ -1,21 +0,0 @@ -// And this was stolen from archey3 -char *LOGO[] = { - " + ", - " # ", - " ### ", - " ##### ", - " ###### ", - " ; #####; ", - " +##.##### ", - " +########## ", - " #############; ", - " ###############+ ", - " ####### ####### ", - " .######; ;###;`'. ", - " .#######; ;#####. ", - " #########. .########` ", - " ######' '###### ", - " ;#### ####; ", - " ##' '## ", - "#' `# " -}; diff --git a/logos/arch3.h b/logos/arch3.h deleted file mode 100644 index 8175ab9..0000000 --- a/logos/arch3.h +++ /dev/null @@ -1,22 +0,0 @@ -// made by Reddit user LnLcFlx2 -char *LOGO[] = { -" ▄ ", -" ▟█▙ ", -" ▟███▙ ", -" ▟█████▙ ", -" ▟███████▙ ", -" ▂▔▀▜██████▙ ", -" ▟██▅▂▝▜█████▙ ", -" ▟█████████████▙ ", -" ▟███████████████▙ ", -" ▟█████████████████▙ ", -" ▟███████████████████▙ ", -" ▟█████████▛▀▀▜████████▙ ", -" ▟████████▛ ▜███████▙ ", -" ▟█████████ ████████▙ ", -" ▟██████████ █████▆▅▄▃▂ ", -" ▟██████████▛ ▜█████████▙ ", -" ▟██████▀▀▀ ▀▀██████▙ ", -" ▟███▀▘ ▝▀███▙ ", -" ▟▛▀ ▀▜▙ " -}; diff --git a/logos/artix.h b/logos/artix.h new file mode 100644 index 0000000..e1644d7 --- /dev/null +++ b/logos/artix.h @@ -0,0 +1,23 @@ +// This was stolen from neofetch +char *LOGO[] = { +" ' ", +" 'o' ", +" 'ooo' ", +" 'ooxoo' ", +" 'ooxxxoo' ", +" 'oookkxxoo' ", +" 'oiioxkkxxoo' ", +" ':;:iiiioxxxoo' ", +" `'.;::ioxxoo' ", +" '-. `':;jiooo' ", +" 'oooio-.. `'i:io' ", +" 'ooooxxxxoio:,. `'-;' ", +" 'ooooxxxxxkkxoooIi:-. `' ", +" 'ooooxxxxxkkkkxoiiiiiji' ", +" 'ooooxxxxxkxxoiiii:'` .i' ", +" 'ooooxxxxxoi:::'` .;ioxo' ", +" 'ooooxooi::'` .:iiixkxxo' ", +" 'ooooi:'` `'';ioxxo' ", +" 'i:'` '':io' ", +"'` `' " +}; diff --git a/logos/debian.h b/logos/debian.h new file mode 100644 index 0000000..409a5b6 --- /dev/null +++ b/logos/debian.h @@ -0,0 +1,21 @@ +// This was stolen from neofetch +char *LOGO[] = { +" _,met$$$$$gg. ", +" ,g$$$$$$$$$$$$$$$P. ", +" ,g$$P\" \"\"\"Y$$.\". ", +" ,$$P' `$$$. ", +"',$$P ,ggs. `$$b: ", +"`d$$' ,$P\"' . $$$ ", +" $$P d$' , $$P ", +" $$: $$. - ,d$$' ", +" $$; Y$b._ _,d$P' ", +" Y$$. `.`\"Y$$$$P\"' ", +" `$$b \"-.__ ", +" `Y$$ ", +" `Y$$. ", +" `$$b. ", +" `Y$$b. ", +" `\"Y$b._ ", +" `\"\"\" " +}; + diff --git a/logos/fedora.h b/logos/fedora.h new file mode 100644 index 0000000..b04fbc8 --- /dev/null +++ b/logos/fedora.h @@ -0,0 +1,21 @@ +// This was stolen from neofetch +char *LOGO[] = { +" /:-------------:\\\\ ", +" :-------------------:: ", +" :-----------/shhOHbmp---:\\\\ ", +" /-----------omMMMNNNMMD ---: ", +" :-----------sMMMMNMNMP. ---: ", +" :-----------:MMMdP------- ---\\\\ ", +",------------:MMMd-------- ---: ", +":------------:MMMd------- .---: ", +":---- oNMMMMMMMMMNho .----: ", +":-- .+shhhMMMmhhy++ .------/ ", +":- -------:MMMd--------------: ", +":- --------/MMMd-------------; ", +":- ------/hMMMy------------: ", +":-- :dMNdhhdNMMNo------------; ", +":---:sdNMMMMNds:------------: ", +":------:://:-------------:: ", +":---------------------:// " +}; + diff --git a/logos/manjaro.h b/logos/manjaro.h new file mode 100644 index 0000000..ebc91e6 --- /dev/null +++ b/logos/manjaro.h @@ -0,0 +1,17 @@ +// This was stolen from neofetch +char *LOGO[] = { + "██████████████████ ████████ ", + "██████████████████ ████████ ", + "██████████████████ ████████ ", + "██████████████████ ████████ ", + "████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ ", + "████████ ████████ ████████ " +}; diff --git a/logos/ubuntu.h b/logos/ubuntu.h new file mode 100644 index 0000000..b2b8d78 --- /dev/null +++ b/logos/ubuntu.h @@ -0,0 +1,22 @@ +// This was stolen from neofetch +char *LOGO[] = { +" ./+o+- ", +" yyyyy- -yyyyyy+ ", +" ://+//////-yyyyyyo ", +" .++ .:/++++++/-.+sss/` ", +" .:++o: /++++++++/:--:/- ", +" o:+o+:++.`..```.-/oo+++++/ ", +" .:+o:+o/. `+sssoo+/ ", +" .++/+:+oo+o:` /sssooo. ", +"/+++//+:`oo+o /::--:. ", +"+/+o+++`o++o ++////. ", +" .++.o+++oo+:` /dddhhh. ", +" .+.o+oo:. `oddhhhh+ ", +" +.++o+o``-````.:ohdhhhhh+ ", +" `:o+++ `ohhhhhhhhyo++os: ", +" .o:`.syhhhhhhh/.oo++o` ", +" /osyyyyyyo++ooo+++/ ", +" ````` +oo+++o: ", +" `oo++. " +}; + diff --git a/paleofetch.c b/paleofetch.c index 72ce826..fe4f2ef 100644 --- a/paleofetch.c +++ b/paleofetch.c @@ -135,7 +135,7 @@ static char *get_title() { title_length = strlen(hostname) + strlen(username) + 1; char *title = malloc(BUF_SIZE); - snprintf(title, BUF_SIZE, COLOR"%s\e[0m@"COLOR"%s", username, hostname); + snprintf(title, BUF_SIZE, TITLECOLOR"%s\e[0m@"TITLECOLOR"%s", username, hostname); return title; } @@ -298,9 +298,9 @@ static char *get_shell() { char *shell_name = strrchr(getenv("SHELL"), '/'); if(shell_name == NULL) /* if $SHELL doesn't have a '/' */ - strncpy(shell, shell_path, BUF_SIZE); /* copy the whole thing over */ + strncpy(shell, shell_path, BUF_SIZE - 1); /* copy the whole thing over */ else - strncpy(shell, shell_name + 1, BUF_SIZE); /* o/w copy past the last '/' */ + strncpy(shell, shell_name + 1, BUF_SIZE - 1); /* o/w copy past the last '/' */ return shell; } @@ -341,7 +341,7 @@ static char *get_resolution() { modes = fopen(modes_file_name, "r"); if (modes != NULL) { if (getline(&line, &len, modes) != -1) { - strncpy(resolution, line, BUF_SIZE); + strncpy(resolution, line, BUF_SIZE - 1); remove_newline(resolution); free(line); @@ -389,10 +389,10 @@ static char *get_terminal() { free(prop); } else { terminal_fallback: - strncpy(terminal, getenv("TERM"), BUF_SIZE); /* fallback to old method */ + strncpy(terminal, getenv("TERM"), BUF_SIZE - 1); /* fallback to old method */ /* in tty, $TERM is simply returned as "linux"; in this case get actual tty name */ if (strcmp(terminal, "linux") == 0) { - strncpy(terminal, ttyname(STDIN_FILENO), BUF_SIZE); + strncpy(terminal, ttyname(STDIN_FILENO), BUF_SIZE - 1); } } @@ -500,10 +500,10 @@ static char *find_gpu(int index) { dev = pacc->devices; while(dev != NULL) { - pci_fill_info(dev, PCI_FILL_IDENT); + pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS); device_class = pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_CLASS, dev->device_class); if(strcmp("VGA compatible controller", device_class) == 0 || strcmp("3D controller", device_class) == 0) { - strncpy(gpu, pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE | PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id), BUF_SIZE); + strncpy(gpu, pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE | PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id), BUF_SIZE - 1); if(gpu_index == index) { found = true; break; @@ -717,13 +717,13 @@ int main(int argc, char *argv[]) { for (int i = 0; i < COUNT(LOGO); i++) { // If we've run out of information to show... if(i >= COUNT(config) - offset) // just print the next line of the logo - printf(COLOR"%s\n", LOGO[i]); + printf(LOGOCOLOR"%s\n", LOGO[i]); else { // Otherwise, we've got a bit of work to do. char *label = config[i+offset].label, *value = get_value(config[i+offset], read_cache, cache_data); if (strcmp(value, "") != 0) { // check if value is an empty string - printf(COLOR"%s%s\e[0m%s\n", LOGO[i], label, value); // just print if not empty + printf(LOGOCOLOR"%s"COLOR"%s\e[0m%s\n", LOGO[i], label, value); // just print if not empty } else { if (strcmp(label, "") != 0) { // check if label is empty, otherwise it's a spacer ++offset; // print next line of information @@ -731,7 +731,7 @@ int main(int argc, char *argv[]) { label = config[i+offset].label; // read new label and value value = get_value(config[i+offset], read_cache, cache_data); } - printf(COLOR"%s%s\e[0m%s\n", LOGO[i], label, value); + printf(LOGOCOLOR"%s"COLOR"%s\e[0m%s\n", LOGO[i], label, value); } free(value);