diff --git a/Makefile b/Makefile index 0617ead..589e9c9 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ PREFIX ?= /usr/local all: afetch -afetch: ${SRC} src/config.h src/colour.h +afetch: ${SRC} src/config.h src/color.h ${CC} ${CFLAGS} ${SRC} ${LDFLAGS} -o afetch debug: diff --git a/src/colour.h b/src/color.h similarity index 88% rename from src/colour.h rename to src/color.h index 8a45425..d037db2 100644 --- a/src/colour.h +++ b/src/color.h @@ -1,4 +1,4 @@ -/* BOLD COLOURS */ +/* BOLD COLORS */ #define BBLACK "\033[1;30m" #define BGRAY "\033[1;90m" #define BRED "\033[1;31m" @@ -8,7 +8,7 @@ #define BMAGENTA "\033[1;35m" #define BCYAN "\033[1;36m" #define BWHITE "\033[1;37m" -/* NORMAL COLOURS */ +/* NORMAL COLORS */ #define BLACK "\033[0;30m" #define RED "\033[0;31m" #define GREEN "\033[0;32m" @@ -19,4 +19,4 @@ #define WHITE "\033[0;37m" /* OTHER */ #define RESET "\033[0;m" -#define BITAL "\033[1;3m" +#define BITAL "\033[1;3m" diff --git a/src/config.h b/src/config.h index 3870584..49bb6df 100644 --- a/src/config.h +++ b/src/config.h @@ -4,21 +4,24 @@ #define UptimeText " UPTIME " // #define ShellText " SHELL " // #define PackageText " PKGS " // +#define EditorText " EDITOR " //󰧭 +#define DeWmText " DE/WM " // +#define ColorsText " COLORS " //󰸌 /* Those two options are mutually exclusive. * Either set one to 'true' or both to 'false'. */ #define ForceLowerCase false #define ForceUpperCase false -/* See options in colour.h file */ -#define TextColour WHITE +/* See options in color.h file */ +#define Textcolor WHITE -#define PrintColours false /* must be either 'true' or 'false' */ -#define ColourCharacter "● " +#define Printcolors true /* must be either 'true' or 'false' */ +#define colorCharacter "▀" -/* Some examples of things you may want to use for your ColourCharacter +/* Some examples of things you may want to use for your colorCharacter ▀ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▉ ▊ ▋ ▌ ▍ ▎ ▏ - █ ▄ ▀ ● + █ ▄ ▀ ●  */ diff --git a/src/fetch.c b/src/fetch.c index 3cfb582..d95a980 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -8,11 +8,11 @@ #include #include -#include "colour.h" +#include "color.h" #include "config.h" struct dist { - char *col1, *col2, *col3, *col4, *col5, *col6, *col7, *col8; + char *col1, *col2, *col3, *col4, *col5, *col6, *col7, *col8, *col9, *col10; char *getPkgCount; }; struct dist info = { @@ -24,9 +24,11 @@ struct dist info = { .col6 = BWHITE " / \\ ", .col7 = BWHITE " / \\ ", .col8 = BWHITE "", + .col9 = BWHITE "", + .col10 = BWHITE "", .getPkgCount = "echo unsupported", }; -char *username, *osname, *shellname, *pkgCount; +char *username, *osname, *shellname, *pkgCount, *editorname, *dewmname; char *krnlver; long uptimeH, uptimeM; @@ -113,6 +115,20 @@ void *shell() return NULL; } +void *editor() +{ + editorname = getenv("EDITOR"); + + return NULL; +} + +void *dewm() +{ + dewmname = getenv("XDG_CURRENT_DESKTOP"); + + return NULL; +} + void *os() { static struct utsname sysInfo; @@ -163,18 +179,22 @@ void *os() info.col5 = BBLUE " / \\ \\ "; info.col6 = BBLUE "/ \\ \\"; info.col7 = BBLUE " \\ "; - info.col8 = BBLUE ""; + info.col8 = BBLUE " "; + info.col9 = BBLUE " "; + info.col10 = BBLUE " "; info.getPkgCount = "grep 'P:' /lib/apk/db/installed | wc -l"; } else if (strncmp(osname, "Arch Linux", 10) == 0) { - info.col1 = BCYAN ""; - info.col2 = BCYAN " /\\ "; - info.col3 = BCYAN " / \\ "; - info.col4 = BCYAN " /\\ \\ "; - info.col5 = BCYAN " / \\ "; - info.col6 = BCYAN " / ,, \\ "; - info.col7 = BCYAN " / | | -\\ "; - info.col8 = BCYAN "/_-'' ''-_\\\n"; + info.col1 = BBLUE ""; + info.col2 = BBLUE " /\\ "; + info.col3 = BBLUE " / \\ "; + info.col4 = BBLUE " /\\ \\ "; + info.col5 = BBLUE " / \\ "; + info.col6 = BBLUE " / ,, \\ "; + info.col7 = BBLUE " / | | -\\ "; + info.col8 = BBLUE "/_-'' ''-_\\"; + info.col9 = BBLUE " "; + info.col10 = BBLUE " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "Arch bang Linux", 15) == 0) { @@ -185,7 +205,9 @@ void *os() info.col5 = BCYAN " / /_/\\ "; info.col6 = BCYAN " / __ \\ "; info.col7 = BCYAN " / /_/\\ \\ "; - info.col8 = BCYAN "/_-'' ''-_\\\n"; + info.col8 = BCYAN "/_-'' ''-_\\"; + info.col9 = BCYAN " "; + info.col10 = BCYAN " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "ArcoLinux", 9) == 0) { info.col1 = BBLUE ""; @@ -195,7 +217,9 @@ void *os() info.col5 = BBLUE " / / \\ \\ "; info.col6 = BBLUE " / / \\ \\ "; info.col7 = BBLUE " / / _____\\ \\ "; - info.col8 = BBLUE "/_/ `----.\\_\\\n"; + info.col8 = BBLUE "/_/ `----.\\_\\"; + info.col9 = BBLUE " "; + info.col10 = BBLUE " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "Artix Linux", 11) == 0) { info.col1 = BCYAN ""; @@ -205,7 +229,9 @@ void *os() info.col5 = BCYAN " / ', "; info.col6 = BCYAN " / ,`\\ "; info.col7 = BCYAN " / ,.'`. \\ "; - info.col8 = BCYAN "/.,'` `'.\\\n"; + info.col8 = BCYAN "/.,'` `'.\\"; + info.col9 = BCYAN " "; + info.col10 = BCYAN " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "CelOS", 5) == 0) { info.col1 = BMAGENTA "\n"; @@ -215,7 +241,9 @@ void *os() info.col5 = BWHITE "__"BMAGENTA"|"BWHITE"_____"BMAGENTA" | "; info.col6 = BMAGENTA " | | "; info.col7 = BMAGENTA " -_"BWHITE" ______"BMAGENTA"/"BWHITE"_ "BMAGENTA; - info.col8 = BMAGENTA " -______/ \n"; + info.col8 = BMAGENTA " -______/ "; + info.col9 = BMAGENTA " "; + info.col10 = BMAGENTA " "; // have to add support for flatpak too info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; /* TO DO: CREATE DEEPIN LOGO */ @@ -228,6 +256,8 @@ void *os() info.col6 = BRED ""; info.col7 = BRED ""; info.col8 = BRED ""; + info.col9 = BRED ""; + info.col10 = BRED ""; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; } else if (strncmp(osname, "Debian GNU/Linux", 16) == 0) { @@ -238,7 +268,9 @@ void *os() info.col5 = BRED "-_ "; info.col6 = BRED " --_ "; info.col7 = BRED " "; - info.col8 = BRED ""; + info.col8 = BRED " "; + info.col9 = BRED " "; + info.col10 = BRED " "; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; } else if (strncmp(osname, "Arch7", 10 ) == 0){ @@ -249,7 +281,9 @@ void *os() info.col5 = BCYAN " / /__\\ \\ "; info.col6 = BCYAN " / /____\\ \\ "; info.col7 = BCYAN " /_/ \\_\\ "; - info.col8 = BCYAN ""; + info.col8 = BCYAN " "; + info.col9 = BCYAN " "; + info.col10 = BCYAN " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "elementary OS", 12) == 0) { info.col1 = BCYAN ""; @@ -259,36 +293,34 @@ void *os() info.col5 = BCYAN "|__\\ / / |"; info.col6 = BCYAN "\\ /__/ /"; info.col7 = BCYAN " \\_______/ "; - info.col8 = BCYAN ""; + info.col8 = BCYAN " "; + info.col9 = BCYAN " "; + info.col10 = BCYAN " "; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; } else if (strncmp(osname, "EndeavourOS", 11) == 0) { info.col1 = BCYAN ""; - info.col2 = - BRED " /" BBLUE "\\ " BCYAN; - info.col3 = BRED " /" BBLUE "/ \\" BCYAN - "\\ " BCYAN; - info.col4 = BRED " /" BBLUE "/ \\ " BCYAN - "\\ " BCYAN; - info.col5 = BRED " / " BBLUE "/ _) " BCYAN - ")" BCYAN; - info.col6 = BRED "/_" BBLUE "/___-- " BCYAN - "__- " BCYAN; + info.col2 = BRED " /" BBLUE "\\ " BCYAN; + info.col3 = BRED " /" BBLUE "/ \\" BCYAN"\\ " BCYAN; + info.col4 = BRED " /" BBLUE "/ \\ " BCYAN"\\ " BCYAN; + info.col5 = BRED " / " BBLUE "/ _) " BCYAN")" BCYAN; + info.col6 = BRED "/_" BBLUE "/___-- " BCYAN"__- " BCYAN; info.col7 = BCYAN " /____-- " BCYAN; - info.col8 = BCYAN ""; + info.col8 = BCYAN " "; + info.col9 = BCYAN " "; + info.col10 = BCYAN " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "Fedora", 6) == 0) { info.col1 = BWHITE " _____\n" BBLUE; info.col2 = BWHITE " / __)" BBLUE "\\ "; info.col3 = BWHITE " | / " BBLUE "\\ \\"; info.col4 = BWHITE " ___| |" BBLUE "__/ /"; - info.col5 = - BBLUE " / " BWHITE "(_ _)" BBLUE "_/ "; - info.col6 = - BBLUE "/ / " BWHITE "| | " BBLUE; - info.col7 = - BBLUE "\\ \\" BWHITE "__/ | " BBLUE; - info.col8 = BBLUE " \\" BWHITE "(_____/" BBLUE; + info.col5 = BBLUE " / " BWHITE "(_ _)" BBLUE "_/ "; + info.col6 = BBLUE "/ / " BWHITE "| | " BBLUE; + info.col7 = BBLUE "\\ \\" BWHITE "__/ | " BBLUE; + info.col8 = BBLUE " \\" BWHITE "(_____/ " BBLUE; + info.col9 = BBLUE " "; + info.col10 = BBLUE " "; info.getPkgCount = "[[ $(which sqlite3 2>/dev/null) && $? -ne " "1 ]] && (sqlite3 " @@ -302,7 +334,9 @@ void *os() info.col5 = BMAGENTA " / _/ "; info.col6 = BMAGENTA " ( _- "; info.col7 = BMAGENTA " \\____- "; - info.col8 = BWHITE "\n"; + info.col8 = BMAGENTA " "; + info.col9 = BMAGENTA " "; + info.col10 = BMAGENTA " "; info.getPkgCount = "qlist -IRv | wc -l"; } else if (strncmp(osname, "KDE neon", 8) == 0) { info.col1 = BGREEN ""; @@ -312,7 +346,9 @@ void *os() info.col5 = BGREEN " | | | |"; info.col6 = BGREEN " \\ --- _/ "; info.col7 = BGREEN " --- "; - info.col8 = BGREEN ""; + info.col8 = BGREEN " "; + info.col9 = BGREEN " "; + info.col10 = BGREEN " "; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; } else if (strncmp(osname, "Linux Mint", 10) == 0) { @@ -323,7 +359,9 @@ void *os() info.col5 = BGREEN " | | | | | | "; info.col6 = BGREEN " | \\_____/ | "; info.col7 = BGREEN " \\___________/ "; - info.col8 = BGREEN "\n"; + info.col8 = BGREEN " "; + info.col9 = BGREEN " "; + info.col10 = BGREEN " "; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; } else if (strncmp(osname, "Manjaro", 7) == 0) { info.col1 = BGREEN " ________ __ \n"; @@ -333,7 +371,9 @@ void *os() info.col5 = BGREEN "| | | | | |"; info.col6 = BGREEN "| | | | | |"; info.col7 = BGREEN "| | | | | |"; - info.col8 = BGREEN "|__| |__| |__|\n"; + info.col8 = BGREEN "|__| |__| |__|"; + info.col9 = BGREEN " "; + info.col10 = BGREEN " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "NixOS", 5) == 0) { info.col1 = BMAGENTA " \n"; @@ -344,6 +384,8 @@ void *os() info.col6 = BMAGENTA " //\\\\___// "; info.col7 = BMAGENTA "// /\\\\ \\\\== "; info.col8 = BMAGENTA " // \\\\ \\\\ "; + info.col9 = BMAGENTA " "; + info.col10 = BMAGENTA " "; info.getPkgCount = "nix-store -q --requisites " "/run/current-system/sw | wc -l"; @@ -357,7 +399,9 @@ void *os() info.col5 = BGREEN " _______|"; info.col6 = BGREEN " \\_______"; info.col7 = BGREEN "__________/"; - info.col8 = BGREEN ""; + info.col8 = BGREEN " "; + info.col9 = BGREEN " "; + info.col10 = BGREEN " "; info.getPkgCount = "rpm -qa | wc -l"; } else if (strncmp(osname, "Parabola", 8) == 0) { info.col1 = BMAGENTA ""; @@ -367,7 +411,9 @@ void *os() info.col5 = BMAGENTA " / .` "; info.col6 = BMAGENTA " /.` "; info.col7 = BMAGENTA " /` "; - info.col8 = BMAGENTA ""; + info.col8 = BMAGENTA " "; + info.col9 = BMAGENTA " "; + info.col10 = BMAGENTA " "; info.getPkgCount = "pacman -Qq | wc -l"; } else if (strncmp(osname, "Pop!_OS", 7) == 0) { info.col1 = BCYAN "______\n"; @@ -378,6 +424,8 @@ void *os() info.col6 = BCYAN " \\ \\ _ "; info.col7 = BCYAN " __\\_\\__(_)_ "; info.col8 = BCYAN " (___________)"; + info.col9 = BCYAN " "; + info.col10 = BCYAN " "; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; } else if (strncmp(osname, "postmarketOS", 13) == 0) { @@ -389,6 +437,8 @@ void *os() info.col6 = BGREEN " / ___\\/ \\ "; info.col7 = BGREEN " / \\ \\ "; info.col8 = BGREEN "/_____/________\\"; + info.col9 = BGREEN " "; + info.col10 = BGREEN " "; info.getPkgCount = "grep 'P:' /lib/apk/db/installed | wc -l"; } else if (strncmp(osname, "Slackware", 10) == 0) { @@ -399,7 +449,9 @@ void *os() info.col5 = BBLUE " ______| | "; info.col6 = BBLUE "| |________/ "; info.col7 = BBLUE "|____________"; - info.col8 = BBLUE ""; + info.col8 = BBLUE " "; + info.col9 = BBLUE " "; + info.col10 = BBLUE " "; info.getPkgCount = "ls /var/log/packages | wc -l"; } else if (strncmp(osname, "Solus", 5) == 0) { @@ -411,6 +463,8 @@ void *os() info.col6 = BMAGENTA " \\--------------/ "; info.col7 = BMAGENTA " \\------------/ "; info.col8 = BMAGENTA " \\----------/"; + info.col9 = BMAGENTA " "; + info.col10 = BMAGENTA " "; info.getPkgCount = "ls /var/lib/eopkg/package/ | wc -l"; } else if (strncmp(osname, "Ubuntu", 6) == 0) { @@ -421,10 +475,12 @@ void *os() info.col5 = BRED "(_) | | "; info.col6 = BRED " \\ --- _/ "; info.col7 = BRED " ---(_) "; - info.col8 = BRED ""; + info.col8 = BRED " "; + info.col9 = BRED " "; + info.col10 = BRED " "; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; - } else if (strncmp(osname, "void", 4) == 0) { + } else if (strncmp(osname, "Void", 4) == 0) { info.col1 = BGREEN " _____\n"; info.col2 = BGREEN " _ \\____ - "; info.col3 = BGREEN " / / ____ \\ \\ "; @@ -432,7 +488,9 @@ void *os() info.col5 = BGREEN " | | " BGRAY BITAL "VOID " BGREEN "| |"; info.col6 = BGREEN " \\ \\ \\____/ / /"; info.col7 = BGREEN " \\ \\____ /_/ "; - info.col8 = BGREEN " -_____\\\n"; + info.col8 = BGREEN " -_____\\ "; + info.col9 = BGREEN " "; + info.col10 = BGREEN " "; info.getPkgCount = "xbps-query -l | wc -l"; } else if (strncmp(osname, "Zorin OS", 8) == 0) { info.col1 = BBLUE " ______ \n"; @@ -442,7 +500,9 @@ void *os() info.col5 = BBLUE "\\ / /"; info.col6 = BBLUE " \\ /___ / "; info.col7 = BBLUE " \\______/ "; - info.col8 = BBLUE ""; + info.col8 = BBLUE " "; + info.col9 = BBLUE " "; + info.col10 = BBLUE " "; info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; } } else if (strncmp(sysInfo.sysname, "Darwin", 6) == 0) { @@ -454,6 +514,8 @@ void *os() info.col6 = BRED " :_________: " BYELLOW; info.col7 = BMAGENTA " :_________`-;" BYELLOW; info.col8 = BBLUE " `.__.-.__.' " BYELLOW; + info.col9 = BBLUE " "; + info.col10 = BBLUE " "; if ((strncmp(sysInfo.machine, "iPhone", 6) == 0) || (strncmp(sysInfo.machine, "iPad", 4) == 0) || (strncmp(sysInfo.machine, "iPod", 4) == 0)) { info.getPkgCount = "dpkg -l | tail -n+6 | wc -l"; @@ -487,7 +549,9 @@ void *os() info.col5 = BRED "| |"; info.col6 = BRED " ; ; "; info.col7 = BRED " '-_____-' "; - info.col8 = BRED ""; + info.col8 = BRED " "; + info.col9 = BRED " "; + info.col10 = BRED " "; info.getPkgCount = "pkg info | wc -l | tr -d ' '"; osname = sysInfo.sysname; } else if (strncmp(sysInfo.sysname, "OpenBSD", 7) == 0) { @@ -498,7 +562,9 @@ void *os() info.col5 = BYELLOW " |_ < ) 3 )"; info.col6 = BYELLOW " / \\ / "; info.col7 = BYELLOW " /-_____-\\ "; - info.col8 = BYELLOW ""; + info.col8 = BYELLOW " "; + info.col9 = BYELLOW " "; + info.col10 = BYELLOW " "; info.getPkgCount = "/bin/ls -1 /var/db/pkg/ | wc -l | tr -d ' '"; osname = sysInfo.sysname; @@ -514,18 +580,18 @@ void *os() return NULL; } -void *colourDraw() +void *colorDraw() { - if (PrintColours == false) + if (Printcolors == false) return NULL; - printf(" "); - for (int i = 30; i < 38; i++) { - printf("\033[0;%dm %s", i, ColourCharacter); - } // print regular term colours - printf("\n "); + //printf(" "); + //for (int i = 30; i < 38; i++) { + // printf("\033[0;%dm %s", i, colorCharacter); + //} // print regular term colors + //printf("\n"); for (int i = 30; i < 38; i++) { - printf("\033[1;%dm %s", i, ColourCharacter); + printf("\033[1;%dm %s", i, colorCharacter); } printf("\n"); @@ -536,32 +602,38 @@ int main() { struct utsname sysInfo; uname(&sysInfo); - pthread_t threads[6]; + pthread_t threads[8]; pthread_create(&threads[0], NULL, user, NULL); pthread_create(&threads[1], NULL, os, NULL); pthread_create(&threads[2], NULL, kernel, NULL); pthread_create(&threads[3], NULL, uptime, NULL); pthread_create(&threads[4], NULL, shell, NULL); + pthread_create(&threads[5], NULL, editor, NULL); + pthread_create(&threads[6], NULL, dewm, NULL); pthread_join(threads[0], NULL); /* os function must be run to get info.col1 */ pthread_join(threads[1], NULL); printf("%s", info.col1); - printf("%s %s%s%s\n", info.col2, UserText, TextColour, username); - printf("%s %s%s%s\n", info.col3, OsText, TextColour, osname); + printf("%s %s%s%s\n", info.col2, UserText, Textcolor, username); + printf("%s %s%s%s\n", info.col3, OsText, Textcolor, osname); pthread_join(threads[2], NULL); - printf("%s %s%s%s\n", info.col4, KernelText, TextColour, krnlver); + printf("%s %s%s%s\n", info.col4, KernelText, Textcolor, krnlver); pthread_join(threads[3], NULL); - printf("%s %s%s%ldh %ldm\n", info.col5, UptimeText, TextColour, uptimeH, + printf("%s %s%s%ldh %ldm\n", info.col5, UptimeText, Textcolor, uptimeH, uptimeM); pthread_join(threads[4], NULL); - printf("%s %s%s%s\n", info.col6, ShellText, TextColour, shellname); - printf("%s %s%s%s\n", info.col7, PackageText, TextColour, pkgCount); - printf("%s\n", info.col8); - - pthread_create(&threads[5], NULL, colourDraw, NULL); + printf("%s %s%s%s\n", info.col6, ShellText, Textcolor, shellname); + printf("%s %s%s%s\n", info.col7, PackageText, Textcolor, pkgCount); pthread_join(threads[5], NULL); + printf("%s %s%s%s\n", info.col8, EditorText, Textcolor, editorname); + pthread_join(threads[6], NULL); + printf("%s %s%s%s\n", info.col9, DeWmText, Textcolor, dewmname); + printf("%s %s", info.col10, ColorsText); + + pthread_create(&threads[7], NULL, colorDraw, NULL); + pthread_join(threads[7], NULL); printf("%s", RESET); return 0; }