Added screenfetch

This commit is contained in:
Cetica Marco
2021-01-04 17:54:22 +01:00
parent f13837f6f8
commit 6f851951d6
15 changed files with 347 additions and 33 deletions

View File

@@ -1,10 +1,10 @@
OBJS = shell.o fetch.o
VER := $(shell git rev-parse --short HEAD)
CC = i686-elf-gcc # cross-compiler
CFLAGS = -DDEFAULT_USER=root -DDEFAULT_HOSTNAME=vulcan -m32 -fno-stack-protector -ffreestanding -Wall -Wextra -Werror -g -c
CFLAGS = -DDEFAULT_USER=root -DDEFAULT_HOSTNAME=vulcan -DVULCAN_VERSION=$(VER) -m32 -fno-stack-protector -ffreestanding -Wall -Wextra -Werror -g -c
all:${OBJS}
all:${OBJS}
%.o: %.c
$(CC) $(CFLAGS) $< -o $@

View File

@@ -3,19 +3,16 @@
#include "../libc/string.h"
#include "../libc/time.h"
#include "../drivers/tty.h"
void system_fetcher() {
/*uint8_t *logo = (uint8_t*)" \n \
__ __ ___ ___ \n \
\\ \\ / / / _ \\/ __| \n \
\\ V / | (_) \\__ \\ \n \
\\_/ \\___/|___/";*/
uint8_t user[64], hostname[64];
#include "../drivers/cpuid.h"
#define STRINGIZE(x) #x
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
static void get_date();
static void get_cpuid();
static void get_version();
void system_fetcher() {
uint8_t user[64], hostname[64];
#ifdef DEFAULT_USER
strcpy(user, (uint8_t*)STRINGIZE_VALUE_OF(DEFAULT_USER));
#else
@@ -27,8 +24,52 @@ void system_fetcher() {
#else
#error "-DDEFAULT_HOSTNAME flag not set"
#endif
printf_color("\n__ __ ___ ___ ", LIGHT_RED, BLACK);
// print first line
printf_color("\n __ __ ___ ___ ", LIGHT_RED, BLACK);
printf_color((char*)user, LIGHT_CYAN, BLACK);
printf_color("@", LIGHT_RED, BLACK);
printf_color((char*)hostname, LIGHT_CYAN, BLACK);
// print second line
printf_color("\n \\ \\ / / / _ \\/ __| ", LIGHT_RED, BLACK);
printf_color("-----------", LIGHT_RED, BLACK);
// print third line
printf_color("\n \\ V / | (_) \\__ \\ ", LIGHT_RED, BLACK);
printf_color("Date: ", LIGHT_CYAN, BLACK);
get_date();
// print fourth line
printf_color("\n \\_/ \\___/|___/ ", LIGHT_RED, BLACK);
get_cpuid();
// print VulcanOS version
get_version();
}
// Date format is D/M/YY
void get_date() {
printf("%d", get_time(TIME_R_DAY)); // Day
printf_color("/", LIGHT_BLUE, BLACK);
printf("%d", get_time(TIME_R_MONTH)); // Month
printf_color("/", LIGHT_BLUE, BLACK);
printf("%d", get_time(TIME_R_YEAR)); // Year
}
void get_cpuid() {
printf_color("CPU type: ", LIGHT_CYAN, BLACK);
printf("%s", (char*)get_cpu_type()); // Print CPU type
printf("%s%s%c", " (", (char*)get_cpu_family(), ')');
}
void get_version() {
uint8_t version[64];
#ifdef VULCAN_VERSION
strcpy(version, (uint8_t*)STRINGIZE_VALUE_OF(VULCAN_VERSION));
#else
#error "-DVULCAN_VERSION flag not set"
#endif
printf_color("\n\t\t\t\t\t Version: ", LIGHT_CYAN, BLACK);
printf_color((char*)version, LIGHT_GREEN, BLACK);
}

View File

@@ -115,6 +115,8 @@ void processCommand(uint8_t *cmd) {
system_fetcher();
else if(strcmp(cmd, (uint8_t*)"reboot") == 0)
reboot();
else if(strcmp(cmd, (uint8_t*)"") == 0)
puts("");
else
puts("\nCommand not found!");
}