From 95e82113def500abb009c522745b3b848a9c1772 Mon Sep 17 00:00:00 2001 From: Joshix-1 <57299889+Joshix-1@users.noreply.github.com> Date: Wed, 21 Jul 2021 12:00:52 +0000 Subject: [PATCH 1/7] Update COPYRIGHT.md fixes the images of Void and OpenSuse --- res/COPYRIGHT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/COPYRIGHT.md b/res/COPYRIGHT.md index e9617af..e9b4dda 100644 --- a/res/COPYRIGHT.md +++ b/res/COPYRIGHT.md @@ -218,7 +218,7 @@ I am not a copyright expert, and maybe I am doing all wrong things, please corre ## OpenSuse -image +image ### Base artwork: @@ -332,7 +332,7 @@ I am not a copyright expert, and maybe I am doing all wrong things, please corre ## VoidLinux -image +image ### Base artwork: From b9eb886d7358522598202262d702c78c42181bec Mon Sep 17 00:00:00 2001 From: Joshix-1 <57299889+Joshix-1@users.noreply.github.com> Date: Wed, 21 Jul 2021 12:02:26 +0000 Subject: [PATCH 2/7] Update COPYRIGHT.md --- res/COPYRIGHT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/COPYRIGHT.md b/res/COPYRIGHT.md index e9b4dda..69aa891 100644 --- a/res/COPYRIGHT.md +++ b/res/COPYRIGHT.md @@ -67,7 +67,7 @@ I am not a copyright expert, and maybe I am doing all wrong things, please corre ## Endeavour OS -image +image ### Base artwork: From b86783c7745d139a2bc0c016d2dcffd43597b137 Mon Sep 17 00:00:00 2001 From: TheDarkBug Date: Wed, 21 Jul 2021 22:36:10 +0200 Subject: [PATCH 3/7] Uwufetch now compiles on freebsd, but there is little to no info. --- Makefile | 9 ++++++++- uwufetch.c | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 17 deletions(-) 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() From c0eb27037cb9f1704fa4e862f2b5318728a700a7 Mon Sep 17 00:00:00 2001 From: TheDarkBug Date: Wed, 21 Jul 2021 22:45:16 +0200 Subject: [PATCH 4/7] Little fix for previous commit --- Makefile | 6 +++--- uwufetch.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7156df3..a143f03 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ NAME = uwufetch FILES = uwufetch.c CFLAGS = -O3 -CFLAGS_DEBUG = -Wall -Wextra -g -thread +CFLAGS_DEBUG = -Wall -Wextra -g -pthread ifeq ($(shell uname), Linux) PREFIX = /usr/bin LIBDIR = /usr/lib @@ -16,8 +16,8 @@ CC = cc MAN_COMPILER = pandoc ifeq ($(shell uname), FreeBSD) -CFLAGS += -D__FREEBSD__ -CFLAGS_DEBUG += -D__FREEBSD__ + CFLAGS += -D__FREEBSD__ + CFLAGS_DEBUG += -D__FREEBSD__ endif diff --git a/uwufetch.c b/uwufetch.c index 85ee0df..b9c81e8 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -378,7 +378,9 @@ void get_info() // os version, cpu and board info FILE *os_release = fopen("/etc/os-release", "r"); +#ifndef __FREEBSD__ FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); +#endif FILE *host_model_info = fopen("/sys/devices/virtual/dmi/id/product_version", "r"); #ifdef __CYGWIN__ iscygwin = 1; @@ -400,10 +402,12 @@ void get_info() break; } } +#ifndef __FREEBSD__ while (fgets(line, sizeof(line), cpuinfo)) if (sscanf(line, "model name : %[^\n]", cpu_model)) break; sprintf(user, "%s", getenv("USER")); +#endif if (iscygwin == 0) fclose(os_release); } From 267e0e3e3088ccab68854e59463c2fe3b8c60ffa Mon Sep 17 00:00:00 2001 From: TheDarkBug Date: Wed, 21 Jul 2021 22:46:31 +0200 Subject: [PATCH 5/7] Little fix for previous commit, again because I am stupid --- uwufetch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uwufetch.c b/uwufetch.c index b9c81e8..e66733c 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -23,8 +23,10 @@ #include #include #else +#ifndef __FREEBSD__ #include #endif +#endif #include #include From 9b43d4df0d02e4269c60c76bebfe4b4128139233 Mon Sep 17 00:00:00 2001 From: TheDarkBug Date: Thu, 22 Jul 2021 18:39:34 +0200 Subject: [PATCH 6/7] Added cpuinfo to freebsd port --- uwufetch.c | 67 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/uwufetch.c b/uwufetch.c index d928f76..6c0817f 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -23,8 +23,10 @@ #include #include #else +#ifndef __FREEBSD__ #include #endif +#endif #include #include @@ -65,8 +67,10 @@ struct package_manager }; struct utsname sys_var; #ifndef __APPLE__ +#ifdef __linux__ struct sysinfo sys; #endif +#endif struct winsize win; int iscygwin = 0; @@ -152,7 +156,11 @@ int main(int argc, char *argv[]) if (argc == 1) parse_config(); if ((argc == 1 && ascii_image_flag == 0) || (argc > 1 && ascii_image_flag == 0)) + { + printf("\n"); // print a new line + printf("\033[1A"); // go up one line if possible print_ascii(); + } else if (ascii_image_flag == 1) print_image(); uwu_kernel(); @@ -338,20 +346,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); } } @@ -370,7 +380,11 @@ void get_info() // os version, cpu and board info FILE *os_release = fopen("/etc/os-release", "r"); +#ifndef __FREEBSD__ FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); +#else + FILE *cpuinfo = popen("sysctl -a | egrep -i 'hw.model'", "r"); +#endif FILE *host_model_info = fopen("/sys/devices/virtual/dmi/id/product_version", "r"); #ifdef __CYGWIN__ iscygwin = 1; @@ -392,8 +406,13 @@ void get_info() break; } } + while (fgets(line, sizeof(line), cpuinfo)) +#ifdef __FREEBSD__ + if (sscanf(line, "hw.model: %[^\n]", cpu_model)) +#else if (sscanf(line, "model name : %[^\n]", cpu_model)) +#endif break; sprintf(user, "%s", getenv("USER")); if (iscygwin == 0) @@ -418,9 +437,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 { @@ -435,7 +456,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) @@ -447,7 +470,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); @@ -893,21 +918,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"); @@ -946,10 +973,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() @@ -1008,8 +1036,11 @@ void uwu_name() void truncate_name(char *name) { - for (int i = target_width; i < 256; i++) - name[i] = '\0'; + char arr[target_width]; + + for (int i = 0; i < target_width; i++) + arr[i] = name[i]; + name = arr; } // remove square brackets (for gpu names) @@ -1026,4 +1057,4 @@ void remove_brackets(char *str) else i++; } -} +} \ No newline at end of file From 3648b00e16d3e7f1a017c19fa76371feee3dcdd5 Mon Sep 17 00:00:00 2001 From: TheDarkBug Date: Thu, 22 Jul 2021 15:31:34 +0200 Subject: [PATCH 7/7] Another little fix for last commit --- uwufetch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/uwufetch.c b/uwufetch.c index c077b7c..255157e 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -406,7 +406,6 @@ void get_info() break; } } -#ifndef __FREEBSD__ while (fgets(line, sizeof(line), cpuinfo)) #ifdef __FREEBSD__ if (sscanf(line, "hw.model: %[^\n]", cpu_model)) @@ -415,7 +414,6 @@ void get_info() #endif break; sprintf(user, "%s", getenv("USER")); -#endif if (iscygwin == 0) fclose(os_release); } @@ -1058,4 +1056,4 @@ void remove_brackets(char *str) else i++; } -} \ No newline at end of file +}