Skip to content

Commit

Permalink
Adding logos(seems color for rockylinux isn't correct)
Browse files Browse the repository at this point in the history
  • Loading branch information
PumpkinXD committed Mar 30, 2024
1 parent 53f915a commit b4c7e43
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 50 deletions.
23 changes: 23 additions & 0 deletions centos_logo_neofetch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

set_colors 3 2 4 5 7


${c1} ..
.PLTJ.
<><><><>
${c2}KKSSV' 4KKK ${c1}LJ${c4} KKKL.'VSSKK
${c2}KKV' 4KKKKK ${c1}LJ${c4} KKKKAL 'VKK
${c2}V' ' 'VKKKK ${c1}LJ${c4} KKKKV' ' 'V
${c2}.4MA.' 'VKK ${c1}LJ${c4} KKV' '.4Mb.
${c4} . ${c2}KKKKKA.' 'V ${c1}LJ${c4} V' '.4KKKKK ${c3}.
${c4} .4D ${c2}KKKKKKKA.'' ${c1}LJ${c4} ''.4KKKKKKK ${c3}FA.
${c4}<QDD ++++++++++++ ${c3}++++++++++++ GFD>
${c4} 'VD ${c3}KKKKKKKK'.. ${c2}LJ ${c1}..'KKKKKKKK ${c3}FV
${c4} ' ${c3}VKKKKK'. .4 ${c2}LJ ${c1}K. .'KKKKKV ${c3}'
${c3} 'VK'. .4KK ${c2}LJ ${c1}KKA. .'KV'
${c3}A. . .4KKKK ${c2}LJ ${c1}KKKKA. . .4
${c3}KKA. 'KKKKK ${c2}LJ ${c1}KKKKK' .4KK
${c3}KKSSA. VKKK ${c2}LJ ${c1}KKKV .4SSKK
${c2} <><><><>
'MKKM'
''
4 changes: 4 additions & 0 deletions src/disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ void output_logo_only(char *distro) {
process_logo_only(solaris_logo, 17);
} else if (STREQ(distro, "Angstrom")) {
process_logo_only(angstrom_logo, 16);
} else if (STREQ(distro, "CentOS Linux")) {
process_logo_only(centos_logo, 19);
} else if (STREQ(distro, "Rocky Linux")) {
process_logo_only(rocky_logo, 19);
} else /* if (STREQ(distro_str, "Linux")) */
{
process_logo_only(linux_logo, 16);
Expand Down
100 changes: 60 additions & 40 deletions src/logos.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,25 +868,25 @@ char *angstrom_logo[] = {" ",


/*copied from neofetch*/
char *neon_logo[] = { TLGN" `..---+/---..` "TNRM,
TLGN" `---.`` `` `.---.` "TNRM,
TLGN" .--.` `` `-:-. "TNRM,
TLGN" `:/: `.----//----.` :/- "TNRM,
TLGN" .:. `---` `--.` .:` "TNRM,
TLGN" .:` `--` .:- `:. "TNRM,
TLGN" `/ `:. `.-::-.` -:` `/` "TNRM,
TLGN" /. /. `:++++++++:` .: .: "TNRM,
TLGN"`/ .: `+++++++++++/ /` `+` "TNRM,
TLGN"/+` -- .++++++++++++` :. .+: "TNRM,
TLGN"`/ .: `+++++++++++/ /` `+` "TNRM,
TLGN" /` /. `:++++++++:` .: .: "TNRM,
TLGN" ./ `:. `.:::-.` -:` `/` "TNRM,
TLGN" .:` `--` .:- `:. "TNRM,
TLGN" .:. `---` `--.` .:` "TNRM,
TLGN" `:/: `.----//----.` :/- "TNRM,
TLGN" .-:.` `` `-:-. "TNRM,
TLGN" `---.`` `` `.---.` "TNRM,
TLGN" `..---+/---..` "TNRM};
char *neon_logo[] = {TLGN " `..---+/---..` " TNRM,
TLGN " `---.`` `` `.---.` " TNRM,
TLGN " .--.` `` `-:-. " TNRM,
TLGN " `:/: `.----//----.` :/- " TNRM,
TLGN " .:. `---` `--.` .:` " TNRM,
TLGN " .:` `--` .:- `:. " TNRM,
TLGN " `/ `:. `.-::-.` -:` `/` " TNRM,
TLGN " /. /. `:++++++++:` .: .: " TNRM,
TLGN "`/ .: `+++++++++++/ /` `+` " TNRM,
TLGN "/+` -- .++++++++++++` :. .+: " TNRM,
TLGN "`/ .: `+++++++++++/ /` `+` " TNRM,
TLGN " /` /. `:++++++++:` .: .: " TNRM,
TLGN " ./ `:. `.:::-.` -:` `/` " TNRM,
TLGN " .:` `--` .:- `:. " TNRM,
TLGN " .:. `---` `--.` .:` " TNRM,
TLGN " `:/: `.----//----.` :/- " TNRM,
TLGN " .-:.` `` `-:-. " TNRM,
TLGN " `---.`` `` `.---.` " TNRM,
TLGN " `..---+/---..` " TNRM};

//15
char *windows_post_modern_logo[] = {
Expand All @@ -907,24 +907,44 @@ char *windows_post_modern_logo[] = {
TLBL "################ ################" TNRM};

//19
char *rocky[] = {" __wgliliiligw_,",
" _williiiiiiliilililw,",
" _%iiiiiilililiiiiiiiiiii_",
" .Qliiiililiiiiiiililililiilm.",
" _iiiiiliiiiiililiiiiiiiiiiliil,",
" .lililiiilililiiiilililililiiiii,",
"_liiiiiiliiiiiiiliiiiiF{iiiiiilili,",
"jliililiiilililiiili@` ~ililiiiiiL",
"iiiliiiiliiiiiiili>` ~liililii",
"liliiiliiilililii` -9liiiil",
"iiiiiliiliiiiii~ \"4lili",
"4ililiiiiilil~| -w, )4lf",
"-liiiiililiF\' _liig, )\'",
" )iiiliii@` _QIililig,",
" )iiii>` .Qliliiiililw",
" )<>~ .mliiiiiliiiiiil,",
" _gllilililiililii~",
" giliiiiiiiiiiiiT`",
" -^~$ililili@~~\'"};

char *centos[]={"???","???"};///TODO: steal centos's ascii art from somewhere
char *rocky_logo[] = {TLGN " __wgliliiligw_," TNRM,
TLGN " _williiiiiiliilililw," TNRM,
TLGN " _%iiiiiilililiiiiiiiiiii_" TNRM,
TLGN " .Qliiiililiiiiiiililililiilm." TNRM,
TLGN " _iiiiiliiiiiililiiiiiiiiiiliil," TNRM,
TLGN " .lililiiilililiiiilililililiiiii," TNRM,
TLGN "_liiiiiiliiiiiiiliiiiiF{iiiiiilili," TNRM,
TLGN "jliililiiilililiiili@` ~ililiiiiiL" TNRM,
TLGN "iiiliiiiliiiiiiili>` ~liililii" TNRM,
TLGN "liliiiliiilililii` -9liiiil" TNRM,
TLGN "iiiiiliiliiiiii~ \"4lili" TNRM,
TLGN "4ililiiiiilil~| -w, )4lf" TNRM,
TLGN "-liiiiililiF\' _liig, )\'" TNRM,
TLGN " )iiiliii@` _QIililig," TNRM,
TLGN " )iiii>` .Qliliiiililw" TNRM,
TLGN " )<>~ .mliiiiiliiiiiil," TNRM,
TLGN " _gllilililiililii~" TNRM,
TLGN " giliiiiiiiiiiiiT`" TNRM,
TLGN " -^~$ililili@~~\'" TNRM};

char *centos_logo[]={
TYLW" .." TNRM,
TYLW" .PLTJ." TNRM,
TYLW" <><><><>" TNRM,
TLGN" KKSSV\' 4KKK "TYLW"LJ"TPUR" KKKL.\'VSSKK" TNRM,
TLGN" KKV\' 4KKKKK "TYLW"LJ"TPUR" KKKKAL \'VKK" TNRM,
TLGN" V\' \' \'VKKKK "TYLW"LJ"TPUR" KKKKV\' \' \'V" TNRM,
TLGN" .4MA.\' \'VKK "TYLW"LJ"TPUR" KKV\' \'.4Mb." TNRM,
TPUR" . "TLGN"KKKKKA.\' \'V "TYLW"LJ"TPUR" V\' \'.4KKKKK "TLBL"."TNRM,
TPUR" .4D "TLGN"KKKKKKKA.\'\' "TYLW"LJ"TPUR" \'\'.4KKKKKKK "TLBL"FA."TNRM,
TPUR"<QDD ++++++++++++ "TLBL"++++++++++++ GFD>"TNRM,
TPUR" \'VD "TLBL"KKKKKKKK\'.. "TLGN"LJ "TYLW"..\'KKKKKKKK "TLBL"FV"TNRM,
TPUR" \' "TLBL"VKKKKK\'. .4 "TLGN"LJ "TYLW"K. .\'KKKKKV "TLBL"\'"TNRM,
TLBL" \'VK\'. .4KK "TLGN"LJ "TYLW"KKA. .\'KV\'" TNRM,
TLBL" A. . .4KKKK "TLGN"LJ "TYLW"KKKKA. . .4" TNRM,
TLBL" KKA. \'KKKKK "TLGN"LJ "TYLW"KKKKK\' .4KK" TNRM,
TLBL" KKSSA. VKKK "TLGN"LJ "TYLW"KKKV .4SSKK" TNRM,
TLGN" <><><><>" TNRM,
TLGN" \'MKKM\'" TNRM,
TLGN" \'\'" TNRM
};
6 changes: 3 additions & 3 deletions src/logos.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ extern char *neon_logo[];

extern char *windows_post_modern_logo[];//"post modern" lol

extern char *rocky[];//reserved
extern char *rocky_logo[];//reserved

extern char *steam[];//reserved for steamdeck
extern char *steam_logo[];//reserved for steamdeck

extern char *centos[];//zit's computers have windows10 and centos7 (vmware)
extern char *centos_logo[];//zit's computers have windows10 and centos7 (vmware)

#endif /* SCREENFETCH_C_LOGOS_H */
2 changes: 2 additions & 0 deletions src/plat/detect_plat.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ void detect_de_windows(void);
* misc functions?
*/
int has_command(const char *cmd);
int has_command2(const char *cmd);
int has_command3(const char *cmd);

#endif
29 changes: 24 additions & 5 deletions src/plat/linux/detect_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,27 @@ void detect_distro_linux(void) {

if (!detected) {
if (FILE_EXISTS("/etc/redhat-release")) {
safe_strncpy(distro_str, "Red Hat Linux", MAX_STRLEN);
safe_strncpy(host_color, TLRD, MAX_STRLEN);
FILE *rh_release_file;
if (FILE_EXISTS("/etc/rocky-release")) {
safe_strncpy(distro_str, "Rocky Linux", MAX_STRLEN);
safe_strncpy(host_color, TLRD, MAX_STRLEN);
}else if (FILE_EXISTS("/etc/almalinux-release")) {
safe_strncpy(distro_str, "AlmaLinux", MAX_STRLEN);
}else if (FILE_EXISTS("/etc/oracle-release")) {
safe_strncpy(distro_str, "Oracle Linux", MAX_STRLEN);
} else if (0) {
/// TODO: Add more Red Hat derivatives
}else {
rh_release_file = fopen("/etc/redhat-release", "r");
fgets(distro_name_str, MAX_STRLEN, rh_release_file);
fclose(rh_release_file);
if (strstr("CentOS", distro_name_str)) {
safe_strncpy(distro_str, "CentOS Linux", MAX_STRLEN);
} else {
safe_strncpy(distro_str, "Red Hat Linux", MAX_STRLEN);
safe_strncpy(host_color, TLRD, MAX_STRLEN);
}
}
} else if (FILE_EXISTS("/etc/fedora-release")) {
safe_strncpy(distro_str, "Fedora", MAX_STRLEN);
safe_strncpy(host_color, TLBL, MAX_STRLEN);
Expand Down Expand Up @@ -163,17 +182,17 @@ void detect_pkgs_linux(void) {
int pkgs;
} opt_pkg;
opt_pkg opt_pkgs[4] = {{"flatpak", 0}, {"snap", 0}, {"brew", 0}, {"nix", 0}};

if (has_command("flatpak")) {
if (has_command3("flatpak --help")) {
glob_t gl_flatpak;
// https://github.com/fastfetch-cli/fastfetch/blob/50da7cabd61c6c7e7930375de4920b93c41aea07/src/detection/packages/packages_linux.c#L198
if (!glob("/var/lib/flatpak/runtime/*", GLOB_NOSORT, NULL, &gl_flatpak)) {
opt_pkgs[0].pkgs += gl_flatpak.gl_pathc;

// printf("%d \n", gl_flatpak.gl_pathc);
globfree(&gl_flatpak);
}
}
if (has_command("snap")) {
if (has_command3("snap")) {
/// TODO: count snap pkgs
}

Expand Down
58 changes: 56 additions & 2 deletions src/plat/unspecified/detect_unknown.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,62 @@ int has_command(const char *cmd) {
free(cmd_line);

status = pclose(fp);
// printf("%d\n",status);
return (status == 0) ? 1 : 0;
}
// int has_command2(const char *cmd){
int has_command2(const char *cmd){
FILE *fp;
int status;

size_t cmd_len = strlen(cmd) + strlen("type -p > /dev/null 2>&1 ") + 1;
char *cmd_line = malloc(cmd_len);
if (cmd_line == NULL) {
perror("malloc");
return -1;
}
snprintf(cmd_line, cmd_len, "type -p %s > /dev/null 2>&1", cmd);

// }
fp = popen(cmd_line, "r");
if (fp == NULL) {
perror("popen");
free(cmd_line);
return -1;
}
free(cmd_line);

status = pclose(fp);
return (status == 0) ? 1 : 0;
}

int has_command3(const char *cmd) {
int status;
pid_t pid = fork();

if (pid == -1) {
perror("fork");
return -1;
}

if (pid == 0) {
int fd = open("/dev/null", O_WRONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
}

dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);

char *argv[] = {"sh", "-c", cmd, NULL};
execv("/bin/sh", argv);

perror("execv");
exit(EXIT_FAILURE);
} else {
if (waitpid(pid, &status, 0) == -1) {
perror("waitpid");
return -1;
}
return WIFEXITED(status) && WEXITSTATUS(status) == 0 ? 1 : 0;
}
}

0 comments on commit b4c7e43

Please sign in to comment.