This commit is contained in:
dqnk 2021-07-23 11:08:10 +02:00
commit 0c7183c5ec
3 changed files with 50 additions and 20 deletions

View file

@ -1,7 +1,7 @@
NAME = uwufetch
FILES = uwufetch.c
CFLAGS = -O3
CFLAGS_DEBUG = -Wall -Wextra
CFLAGS_DEBUG = -Wall -Wextra -g -pthread
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)

View file

@ -67,7 +67,7 @@ I am not a copyright expert, and maybe I am doing all wrong things, please corre
## Endeavour OS
<img title="Endowo Os" src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/endeavour.png" alt="image" width="100">
<img title="Endowo Os" src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/endeavouros.png" alt="image" width="100">
### Base artwork:
@ -218,7 +218,7 @@ I am not a copyright expert, and maybe I am doing all wrong things, please corre
## OpenSuse
<img title="OwOsuse" src='https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/"opensuse-leap".png' alt="image" width="100">
<img title="OwOsuse" src='https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/opensuse-leap.png' alt="image" width="100">
### Base artwork:
@ -332,7 +332,7 @@ I am not a copyright expert, and maybe I am doing all wrong things, please corre
## VoidLinux
<img title="Owoid" src='https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/"void".png' alt="image" width="100">
<img title="Owoid" src='https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/void.png' alt="image" width="100">
### Base artwork:

View file

@ -23,8 +23,10 @@
#include <sys/sysctl.h>
#include <time.h>
#else
#ifndef __FREEBSD__
#include <sys/sysinfo.h>
#endif
#endif
#include <sys/utsname.h>
#include <sys/ioctl.h>
@ -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;
@ -342,7 +346,9 @@ void print_info()
#ifdef __APPLE__
uptime = uptime_mac();
#else
#ifndef __FREEBSD__
uptime = sys.uptime;
#endif
#endif
switch (uptime)
{
@ -374,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;
@ -397,7 +407,11 @@ void get_info()
}
}
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)
@ -422,9 +436,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 +455,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 +469,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);
@ -906,12 +926,14 @@ void uwu_kernel()
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,7 +972,8 @@ 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