diff --git a/Makefile b/Makefile index d5bda47..7156df3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ NAME = uwufetch FILES = uwufetch.c CFLAGS = -O3 -CFLAGS_DEBUG = -Wall -Wextra +CFLAGS_DEBUG = -Wall -Wextra -g -thread ifeq ($(shell uname), Linux) PREFIX = /usr/bin LIBDIR = /usr/lib @@ -11,9 +11,16 @@ else ifeq ($(shell uname), Darwin) LIBDIR = /usr/local/lib MANDIR = /usr/local/share/man/man1 endif + CC = cc MAN_COMPILER = pandoc +ifeq ($(shell uname), FreeBSD) +CFLAGS += -D__FREEBSD__ +CFLAGS_DEBUG += -D__FREEBSD__ +endif + + build: $(FILES) $(CC) $(CFLAGS) -o $(NAME) $(FILES) diff --git a/uwufetch.c b/uwufetch.c index 3a838e6..85ee0df 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -65,8 +65,10 @@ struct package_manager }; struct utsname sys_var; #ifndef __APPLE__ +#ifdef __linux__ struct sysinfo sys; #endif +#endif struct winsize win; int iscygwin = 0; @@ -153,7 +155,7 @@ int main(int argc, char *argv[]) parse_config(); if ((argc == 1 && ascii_image_flag == 0) || (argc > 1 && ascii_image_flag == 0)) { - printf("\n"); // print a new line + printf("\n"); // print a new line printf("\033[1A"); // go up one line if possible print_ascii(); } @@ -342,20 +344,22 @@ void print_info() #ifdef __APPLE__ uptime = uptime_mac(); #else +#ifndef __FREEBSD__ uptime = sys.uptime; +#endif #endif switch (uptime) { - case 0 ... 3599: - printf("\033[18C%s%sUWUPTIME %s%lim\n", + case 0 ... 3599: + printf("\033[18C%s%sUWUPTIME %s%lim\n", NORMAL, BOLD, NORMAL, uptime / 60 % 60); - break; - case 3600 ... 86399: - printf("\033[18C%s%sUWUPTIME %s%lih, %lim\n", + break; + case 3600 ... 86399: + printf("\033[18C%s%sUWUPTIME %s%lih, %lim\n", NORMAL, BOLD, NORMAL, uptime / 3600, uptime / 60 % 60); - break; - default: - printf("\033[18C%s%sUWUPTIME %s%lid, %lih, %lim\n", + break; + default: + printf("\033[18C%s%sUWUPTIME %s%lid, %lih, %lim\n", NORMAL, BOLD, NORMAL, uptime / 86400, uptime / 3600 % 24, uptime / 60 % 60); } } @@ -422,9 +426,11 @@ void get_info() while (fgets(line, sizeof(line), host_model_info)) if (sscanf(line, "%[^\n]", host_model)) break; +#ifndef __FREEBSD__ while (fgets(line, sizeof(line), cpuinfo)) if (sscanf(line, "Hardware : %[^\n]", cpu_model)) break; +#endif } else if (library) // macOS { @@ -439,7 +445,9 @@ void get_info() else sprintf(version_name, "unknown"); } +#ifndef __FREEBSD__ fclose(cpuinfo); +#endif gethostname(host, 256); sscanf(getenv("SHELL"), "%s", shell); if (strlen(shell) > 16) @@ -451,7 +459,9 @@ void get_info() // system resources uname(&sys_var); #ifndef __APPLE__ +#ifndef __FREEBSD__ sysinfo(&sys); // somehow this function has to be called again in print_info() +#endif #endif truncate_name(sys_var.release); @@ -897,21 +907,23 @@ void usage(char *arg) void uwu_kernel() { - #define KERNEL_TO_UWU(str, original, uwufied) \ - if (strcmp(str, original) == 0) \ - sprintf(str, "%s", uwufied) +#define KERNEL_TO_UWU(str, original, uwufied) \ + if (strcmp(str, original) == 0) \ + sprintf(str, "%s", uwufied) char *temp_kernel = kernel; char *token; char splitted[16][128] = {}; int count = 0; - while((token = strsep(&temp_kernel, " "))) { + while ((token = strsep(&temp_kernel, " "))) + { strcpy(splitted[count], token); count++; } strcpy(kernel, ""); - for(int i = 0;i < 16;i++) { + for (int i = 0; i < 16; i++) + { // kernel name KERNEL_TO_UWU(splitted[i], "Linux", "Linuwu"); @@ -950,10 +962,11 @@ void uwu_kernel() // Windows KERNEL_TO_UWU(splitted[i], "windows", "WinyandOwOws"); - if(i != 0) strcat(kernel, " "); + if (i != 0) + strcat(kernel, " "); strcat(kernel, splitted[i]); } - #undef KERNEL_TO_UWU +#undef KERNEL_TO_UWU } void uwu_name()