Reworked quite a lot

This commit is contained in:
Јован Ђокић-Шумарац 2021-05-26 12:23:42 +02:00
parent 54491b7e71
commit 167bf81633
4 changed files with 283 additions and 360 deletions

View file

@ -1,7 +1,7 @@
PREFIX = /usr/local PREFIX = /usr/local
CC = gcc CC = gcc
CFLAGS = -lm CFLAGS = -lm -g -O0
all: fetchy all: fetchy

BIN
fetchy

Binary file not shown.

448
fetchy.c
View file

@ -2,72 +2,77 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <dirent.h> // directory management
#include <dirent.h>
#define BUF_SIZE 50 #define BUF_SIZE 50
#define COLS 8
#define ROWS 100
#define SUPPORTED_OS "xadurm"
#define ARCH_BASED "axmr"
#define DEBIAN_BASED "du"
void truncate_spaces_leading(char *str); #include "logos.h"
void truncate_spaces_trailing(char *str);
void truncate_spaces(char *str);
void read_line(char x); void read_line(char x);
void cache_info(char *cache_path, char **cpu_name, char **gpu); void cache_info(char *cache_path, char **cpu_name, char **gpu, char *os_table);
static int count_files(DIR *package_dir); static int count_files(DIR *package_dir);
static char *get_sys(char *ascii, char *sys, char *os_name); static char *get_sys(char *s_os, char *os_name, char *os_table);
static char *get_kernel(char *kern_name); static char *get_kernel(char *kern_name);
static char *get_uptime(char *uptime); static char *get_uptime(char *uptime);
static char *get_RAM(char *ram_info); static char *get_RAM(char *ram_info);
static char *get_cpu(char *cpuname); static char *get_cpu(char *cpuname);
static char *get_gpu(char *gpu); static char *get_gpu(char *gpu);
static char *get_packages(char *package_count, char sys); static char *get_packages(char *package_count);
void concatenate_and_print(char ascii, char sys, char *os, char *cpu_name, char *gpu); void concatenate_print(char *os, char *cpu_name, char *gpu);
char sys;
int logo_number = 0;
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
char sys, ascii,
*os_name = NULL,
*cpu_name = NULL,
*gpu = NULL,
*os = malloc(BUF_SIZE),
*cache_path = malloc(BUF_SIZE * 2);
cache_info(cache_path, &cpu_name, &gpu); char *os_name = NULL,
os = get_sys(&ascii, &sys, os_name); *cpu_name = NULL,
*gpu = NULL,
*os = malloc(BUF_SIZE),
*os_table = malloc(BUF_SIZE * 2),
*cache_path = malloc(BUF_SIZE * 2),
*s_os = SUPPORTED_OS;
if ( argv[1] != NULL ){
cache_info(cache_path, &cpu_name, &gpu, os_table);
os = get_sys(s_os, os_name, os_table);
if ( argv[1] != NULL ) {
switch ( *(argv[1] + 1) ){ if ( strchr(SUPPORTED_OS, *(argv[1] + 1)) )
logo_number = (int) (strchr(s_os, *(argv[1] + 1) ) - s_os);
case 'a':
case 'x': else {
case 'r': fprintf(stderr, "\n\nArgument not supported\n\n");
case 'u': exit(EXIT_FAILURE);
case 'd': }
case 'm': }
case 'o':
case 'v':
ascii = *(argv[1] + 1) ;
break;
default:
printf("\n\nArgument not supported\n\n");
exit(EXIT_FAILURE);
}
}
//This one is in logos.h
concatenate_and_print(ascii, sys, os, cpu_name, gpu);
concatenate_print( os, cpu_name, gpu);
free(os_name); free(os_name);
@ -76,24 +81,24 @@ int main(int argc, char *argv[]){
free(cache_path); free(cache_path);
return 0; return EXIT_SUCCESS;
} }
void read_line(char x){ void read_line(char x) {
int c; int c;
while (( c = getchar()) != x && c != EOF) { } while (( c = getchar()) != x && c != EOF) { }
} }
// taken from https://github.com/ss7m/paleofetch
void truncate_spaces_leading(char *str){
int src = 0, dst = 0; void truncate_spaces(char *str) {
while(*(str + dst) == ' ') dst++; int src = 0, dst = 0, index, i = -1;
while(*(str + dst) == ' ') dst++;
while(*(str + dst) != '\0') { while(*(str + dst) != '\0') {
*(str + src) = *(str + dst); *(str + src) = *(str + dst);
@ -104,20 +109,12 @@ void truncate_spaces_leading(char *str){
} }
*(str + src) = '\0'; *(str + src) = '\0';
}
void truncate_spaces_trailing(char *str){
int index, i = -1;
i = 0; i = 0;
while(str[i] != '\0'){ while(str[i] != '\0'){
if(str[i] != ' ' && str[i] != '\t' && str[i] != '\n'){ if(str[i] != ' ' && str[i] != '\t' && str[i] != '\n'){
index= i; index= i;
} }
i++; i++;
} }
@ -127,33 +124,34 @@ void truncate_spaces_trailing(char *str){
void cache_info(char *cache_path, char **cpu_name, char **gpu, char *os_table) {
void cache_info(char *cache_path, char **cpu_name, char **gpu){ snprintf(cache_path, BUF_SIZE * 2, "%s/.local/share/fetchy.cache", getenv("HOME"));
FILE *FCache = NULL;
snprintf(cache_path, BUF_SIZE * 2, "%s/.local/share/fetchy.cache", getenv("HOME")); if( (FCache = fopen(cache_path, "r")) ){
FILE *FCache = NULL; *cpu_name = malloc(BUF_SIZE * 4);
*gpu = malloc(BUF_SIZE * 4);
if( (FCache = fopen(cache_path, "r")) ){ char *line = malloc(BUF_SIZE * 4);
*cpu_name = malloc(BUF_SIZE * 4);
*gpu = malloc(BUF_SIZE * 4);
char *line = malloc(BUF_SIZE * 4); fgets(line, BUF_SIZE * 4, FCache);
truncate_spaces(line);
snprintf(*cpu_name, BUF_SIZE * 4, "\x1b[36mCPU\x1b[0m -> %s", strchr(line, ':') +2);
fgets(line, BUF_SIZE * 4, FCache); fgets(line, BUF_SIZE * 4, FCache);
snprintf(*cpu_name, BUF_SIZE * 4, "\x1b[36mCPU\x1b[0m -> %s", strchr(line, ':') +2); truncate_spaces(line);
truncate_spaces_trailing(*cpu_name); snprintf(*gpu, BUF_SIZE * 4, "\x1b[36mGPU\x1b[0m -> %s", strchr(line, ':') +2);
fgets(line, BUF_SIZE * 4, FCache); fgets(os_table, BUF_SIZE * 2, FCache);
snprintf(*gpu, BUF_SIZE * 4, "\x1b[36mGPU\x1b[0m -> %s", strchr(line, ':') +2);
truncate_spaces_trailing(*gpu);
fclose(FCache); fclose(FCache);
free(line); free(line);
} }
else { else {
FCache = fopen(cache_path, "w"); FCache = fopen(cache_path, "w");
if( FCache == NULL ){ if( FCache == NULL ){
printf("\nCan't open cache file.\n"); printf("\nCan't open cache file.\n");
@ -161,107 +159,84 @@ void cache_info(char *cache_path, char **cpu_name, char **gpu){
} }
fprintf(FCache, "CPU : %s\n", get_cpu(*cpu_name)); fprintf(FCache, "CPU : %s\n", get_cpu(*cpu_name));
fprintf(FCache, "GPU : %s\n", get_gpu(*gpu)); fprintf(FCache, "GPU : %s\n", get_gpu(*gpu));
fclose(FCache); fprintf(FCache, "a:Arch|x:Artix|r:Arco|m:Manjaro|u:Ubuntu|d:Debian\n");
printf("\n\aFILE CACHING DONE!! \n\nValues returned : \nCPU -> %s\nGPU -> %s\n\n Caching occurs only once, every subsequent execution will run program normally. Enjoy!\n\n", get_cpu(*cpu_name), get_gpu(*gpu)); fclose(FCache);
free(*cpu_name); free(*gpu);
exit(0);
} printf("\n FILE CACHING DONE!!\n");
printf("Caching occurs only once,\n");
printf("every subsequent execution will\n");
printf("run program normally. Enjoy!\n\n");
cache_info(cache_path, cpu_name, gpu, os_table);
}
} }
static int count_files(DIR *package_dir){ static int count_files(DIR *package_dir) {
struct dirent * entry; struct dirent * entry;
int file_count = 0; int file_count = 0;
while ((entry = readdir(package_dir)) != NULL) { while ((entry = readdir(package_dir)) != NULL) {
if (entry->d_type == DT_DIR) { if (entry->d_type == DT_DIR) {
file_count++; file_count++;
} }
} }
closedir(package_dir); closedir(package_dir);
return file_count; return file_count;
} }
static char *get_sys(char *ascii, char *sys, char *os_name){ static char *get_sys(char *s_os, char *os_name, char *os_table) {
os_name = malloc(BUF_SIZE);
char *name = malloc(BUF_SIZE); os_name = malloc(BUF_SIZE);
FILE *sysName = fopen("/etc/issue", "rt"); char *name = malloc(BUF_SIZE);
FILE *sysName = fopen("/etc/issue", "rt");
if( sysName == NULL ){ if( sysName == NULL ){
printf("\nCan't get os name\n"); fprintf(stderr, "\nCan't get os name\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fscanf(sysName, "%s ", name); fscanf(sysName, "%s ", name);
fclose(sysName); fclose(sysName);
truncate_spaces_leading(name); truncate_spaces(name);
if ( !strcmp( name, "Artix") ) {
*sys = 'x';
*ascii = 'x';
}
if ( !strcmp( name, "Arch") ) {
*sys = 'a';
*ascii = 'a';
}
if ( !strcmp( name, "Manjaro") ) { sys = *(strstr(os_table, name) - 2);
*sys = 'm';
*ascii = 'm'; logo_number = (int) (strchr(s_os, sys) - s_os);
}
if( sys == 'r' )
snprintf(os_name, BUF_SIZE, "\x1b[36mOS\x1b[0m -> %s", name);
else
snprintf(os_name, BUF_SIZE, "\x1b[36mOS\x1b[0m -> %s Linux", name);
free(name);
if ( !strcmp( name, "ArcoLinux") ) { return os_name;
*sys = 'r';
*ascii = 'r';
}
if ( !strcmp( name, "Debian")) {
*sys = 'd';
*ascii = 'd';
}
if ( !strcmp( name, "Ubuntu")) {
*sys = 'u';
*ascii = 'u';
}
if( *sys == 'r' )
snprintf(os_name, BUF_SIZE, "\x1b[36mOS\x1b[0m -> %s", name);
else
snprintf(os_name, BUF_SIZE, "\x1b[36mOS\x1b[0m -> %s Linux", name);
free(name);
return os_name;
} }
static char *get_cpu(char *cpu_name){ static char *get_cpu(char *cpu_name){
char *line = malloc(BUF_SIZE * 4); char *line = malloc(BUF_SIZE * 4);
cpu_name = malloc(BUF_SIZE * 4); cpu_name = malloc(BUF_SIZE * 4);
FILE *cpu = fopen("/proc/cpuinfo", "rt"); FILE *cpu = fopen("/proc/cpuinfo", "rt");
if( cpu == NULL ){ if( cpu == NULL ){
printf("\nCan't get cpu info\n"); printf("\nCan't get cpu info\n");
@ -269,16 +244,16 @@ static char *get_cpu(char *cpu_name){
} }
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
fgets(line, BUF_SIZE * 4, cpu); fgets(line, BUF_SIZE * 4, cpu);
snprintf(cpu_name, BUF_SIZE * 4, "%s", strchr(line, ':') +2); snprintf(cpu_name, BUF_SIZE * 4, "%s", strchr(line, ':') +2);
truncate_spaces_trailing(cpu_name); truncate_spaces(cpu_name);
fclose(cpu); fclose(cpu);
free(line); free(line);
return cpu_name; return cpu_name;
} }
@ -286,21 +261,21 @@ static char *get_cpu(char *cpu_name){
static char *get_gpu(char *gpu){ static char *get_gpu(char *gpu){
gpu = malloc(BUF_SIZE * 3); gpu = malloc(BUF_SIZE * 3);
FILE *gpuName = popen("lspci -v | grep VGA -m 1 | awk -F'[' '{ print $2 }' | awk -F']' '{ print $1 }' ", "r"); FILE *gpuName = popen("lspci -v | grep VGA -m 1 | awk -F'[' '{ print $2 }' | awk -F']' '{ print $1 }' ", "r");
fscanf(gpuName, "%[^\n]%s", gpu); fscanf(gpuName, "%[^\n]%s", gpu);
truncate_spaces_leading(gpu); truncate_spaces(gpu);
truncate_spaces_trailing(gpu);
fclose(gpuName); fclose(gpuName);
if(strstr(gpu, "VGA")) if(strstr(gpu, "VGA"))
strcpy(gpu, "CPU's integrated graphics"); strcpy(gpu, "CPU's integrated graphics");
return gpu; return gpu;
} }
@ -308,9 +283,9 @@ static char *get_gpu(char *gpu){
static char *get_kernel(char *kern_name){ static char *get_kernel(char *kern_name){
kern_name = malloc(BUF_SIZE); kern_name = malloc(BUF_SIZE);
char *kernel = malloc(BUF_SIZE); char *kernel = malloc(BUF_SIZE);
FILE *kInfo = fopen("/proc/version", "rt"); FILE *kInfo = fopen("/proc/version", "rt");
if( kInfo == NULL ){ if( kInfo == NULL ){
printf("\nCan't get kernel info\n"); printf("\nCan't get kernel info\n");
@ -319,14 +294,14 @@ static char *get_kernel(char *kern_name){
fscanf(kInfo, "Linux version %s ", kernel); fscanf(kInfo, "Linux version %s ", kernel);
fclose(kInfo); fclose(kInfo);
truncate_spaces_leading(kernel); truncate_spaces(kernel);
snprintf(kern_name, BUF_SIZE + 5, "\x1b[36mKERN\x1b[0m -> Linux %s", kernel); snprintf(kern_name, BUF_SIZE + 5, "\x1b[36mKERN\x1b[0m -> Linux %s", kernel);
free(kernel); free(kernel);
return kern_name; return kern_name;
} }
@ -334,12 +309,12 @@ static char *get_kernel(char *kern_name){
static char *get_uptime(char *uptime){ static char *get_uptime(char *uptime){
int sec, int sec,
hr, hr,
min; min;
FILE *FUp = fopen("/proc/uptime", "rt"); FILE *FUp = fopen("/proc/uptime", "rt");
uptime = malloc(BUF_SIZE); uptime = malloc(BUF_SIZE);
if( FUp == NULL ){ if( FUp == NULL ){
@ -349,52 +324,42 @@ static char *get_uptime(char *uptime){
fscanf(FUp, "%d", &sec); fscanf(FUp, "%d", &sec);
fclose(FUp); fclose(FUp);
hr = (sec/60/60%24); hr = (sec/60/60%24);
min = (sec/60%60); min = (sec/60%60);
snprintf(uptime, BUF_SIZE, "\x1b[36mUPT\x1b[0m -> %dh, %dmin", hr, min); snprintf(uptime, BUF_SIZE, "\x1b[36mUPT\x1b[0m -> %dh, %dmin", hr, min);
return uptime; return uptime;
} }
static char *get_packages(char *package_count, char sys){ static char *get_packages(char *package_count){
int pkg_count = 0; int pkg_count = 0;
package_count = malloc(BUF_SIZE); package_count = malloc(BUF_SIZE);
switch (sys){ if( strchr(ARCH_BASED, sys) )
pkg_count = count_files(opendir("/var/lib/pacman/local"));
case 'r': else if( strchr(DEBIAN_BASED, sys) )
case 'x': pkg_count = count_files(opendir("/usr/bin")) + count_files(opendir("/sbin"));
case 'a':
case 'm':
pkg_count = count_files(opendir("/var/lib/pacman/local"));
break;
case 'd':
case 'u':
pkg_count = count_files(opendir("/usr/bin")) + count_files(opendir("/sbin")); else{
break; printf("\n\n\aUnable to find package list\n\n");
exit(EXIT_FAILURE);
}
snprintf(package_count, BUF_SIZE, "\x1b[36mPKGS\x1b[0m -> %d", pkg_count);
default:
printf("\n\n\aUnable to find package list\n\n"); return package_count;
exit(EXIT_FAILURE);
}
snprintf(package_count, BUF_SIZE, "\x1b[36mPKGS\x1b[0m -> %d", pkg_count);
return package_count;
} }
@ -402,51 +367,78 @@ static char *get_packages(char *package_count, char sys){
static char *get_RAM(char *ram_info){ static char *get_RAM(char *ram_info){
int bar_percent; int bar_percent;
float total, float total,
free_mem, free_mem,
used, used,
real_percent; real_percent;
ram_info = malloc(BUF_SIZE * 3); ram_info = malloc(BUF_SIZE * 3);
char *line = malloc(BUF_SIZE * 3), char *line = malloc(BUF_SIZE * 3),
bar[] = "[----------]"; bar[] = "[----------]";
FILE *RAM = fopen("/proc/meminfo", "rt"); FILE *RAM = fopen("/proc/meminfo", "rt");
fgets(line, BUF_SIZE * 3, RAM); fgets(line, BUF_SIZE * 3, RAM);
truncate_spaces_leading(line); truncate_spaces(line);
sscanf(line, " MemTotal: %f", &total); sscanf(line, " MemTotal: %f", &total);
fgets(line, BUF_SIZE * 3, RAM); fgets(line, BUF_SIZE * 3, RAM);
fgets(line, BUF_SIZE * 3, RAM); fgets(line, BUF_SIZE * 3, RAM);
truncate_spaces_leading(line); truncate_spaces(line);
sscanf(line, " MemAvailable: %f", &free_mem); sscanf(line, " MemAvailable: %f", &free_mem);
fclose(RAM); fclose(RAM);
used = total - free_mem; used = total - free_mem;
real_percent = (used / total) * 100; real_percent = (used / total) * 100;
bar_percent = (real_percent / 10 + 0.35); bar_percent = (real_percent / 10 + 0.35);
for( int i = 1; i <= bar_percent; i++){ for( int i = 1; i <= bar_percent; i++){
bar[i] = '*'; bar[i] = '*';
} }
snprintf(ram_info, BUF_SIZE * 3, "\x1b[36mRAM\x1b[0m -> %.2f GB of %.2f GB, %s -> %.2f %%", used / 1000000, total / 1000000, bar, real_percent); snprintf(ram_info, BUF_SIZE * 3, "\x1b[36mRAM\x1b[0m -> %.2f GB of %.2f GB, %s -> %.2f %%", used / 1000000, total / 1000000, bar, real_percent);
free(line); free(line);
return ram_info; return ram_info;
} }
#include "logos.h" void concatenate_print(char *os, char *cpu_name, char *gpu){
char *uptime = NULL,
*kern_name = NULL,
*ram_info = NULL,
*package_count = NULL;
strcat( (logo + logo_number)->logo[0], os);
strcat( (logo + logo_number)->logo[1], get_kernel(kern_name));
strcat( (logo + logo_number)->logo[2], get_uptime(uptime));
strcat( (logo + logo_number)->logo[3], get_packages(package_count));
strcat( (logo + logo_number)->logo[4], cpu_name);
strcat( (logo + logo_number)->logo[5], gpu);
strcat( (logo + logo_number)->logo[6], get_RAM(ram_info));
for(int i = 0; i < COLS ; i++)
printf("%s\n", (logo + logo_number)->logo[i]);
free(uptime);
free(ram_info);
free(kern_name);
free(package_count);
}

193
logos.h
View file

@ -1,147 +1,78 @@
void concatenate_and_print(char ascii, char sys, char *os, char *cpu_name, char *gpu){
typedef struct s_logos {
char *uptime = NULL,
*kern_name = NULL,
*ram_info = NULL,
*package_count = NULL;
switch(ascii){
case 'a':
printf("\n");
printf("\x1b[1m . %s\n", os);
printf("\x1b[1m / \\ %s\n", get_kernel(kern_name));
printf("\x1b[1m / \\ %s\n", get_uptime(uptime));
printf("\x1b[1m /^. \\ %s\n", get_packages(package_count, sys));
printf("\x1b[1m / .-. \\ %s\n", cpu_name);
printf("\x1b[1m / ( ) _\\ %s\n", gpu);
printf("\x1b[1m / _.~ ~._^\\ %s\n", get_RAM(ram_info));
printf("\x1b[1m /.^ ^.\\ \n");
printf("\n\n");
break;
char logo[COLS][ROWS];
case 'x':
} t_logos;
printf("\n");
printf("\x1b[1m /\\ %s\n", os);
printf("\x1b[1m / \\ %s\n", get_kernel(kern_name));
printf("\x1b[1m /`'.,\\ %s\n", get_uptime(uptime));
printf("\x1b[1m / ', %s\n", get_packages(package_count, sys));
printf("\x1b[1m / ,`\\ %s\n", cpu_name);
printf("\x1b[1m / ,.'`. \\ %s\n", gpu);
printf("\x1b[1m /.,'` `'.\\ %s\n", get_RAM(ram_info));
printf("\n\n");
break;
t_logos logo[6] = {
case 'd': { "\x1b[1m /\\ ",
"\x1b[1m / \\ ",
printf("\n"); "\x1b[1m /`'.,\\ ",
printf("\x1b[1m _____ %s\n", os); "\x1b[1m / ', ",
printf("\x1b[1m / __ \\ %s\n", get_kernel(kern_name)); "\x1b[1m / ,`\\ ",
printf("\x1b[1m | / | %s\n", get_uptime(uptime)); "\x1b[1m / ,.'`. \\ ",
printf("\x1b[1m | \\___- %s\n", get_packages(package_count, sys)); "\x1b[1m /.,'` `'.\\ "
printf("\x1b[1m -_ %s\n", cpu_name); },
printf("\x1b[1m --_ %s\n", gpu);
printf("\x1b[1m %s\n", get_RAM(ram_info));
printf("\n\n");
break;
case 'u':
printf("\n");
printf("\x1b[1m _ %s\n", os);
printf("\x1b[1m ---(_) %s\n", get_kernel(kern_name));
printf("\x1b[1m _/ --- \\ %s\n", get_uptime(uptime));
printf("\x1b[1m (_) | | %s\n", get_packages(package_count, sys));
printf("\x1b[1m \\ --- / %s\n", cpu_name);
printf("\x1b[1m ---(_) %s\n", gpu);
printf("\x1b[1m %s\n", get_RAM(ram_info));
printf("\n\n");
break;
case 'r': { "\x1b[1m . ",
"\x1b[1m / \\ ",
printf("\n"); "\x1b[1m / \\ ",
printf("\x1b[1m /\\ %s\n", os); "\x1b[1m /^. \\ ",
printf("\x1b[1m / \\ %s\n", get_kernel(kern_name)); "\x1b[1m / .-. \\ ",
printf("\x1b[1m / /\\ \\ %s\n", get_uptime(uptime)); "\x1b[1m / ( ) _\\ ",
printf("\x1b[1m / / \\ \\ %s\n", get_packages(package_count, sys)); "\x1b[1m / _.~ ~._^\\ ",
printf("\x1b[1m / / \\ \\ %s\n", cpu_name); "\x1b[1m /.^ ^.\\ "
printf("\x1b[1m / / _____\\ \\ %s\n", gpu); },
printf("\x1b[1m /_/ \\`----.\\_\\ %s\n", get_RAM(ram_info));
printf("\n\n");
break;
case 'm': { "\x1b[1m _____ ",
"\x1b[1m / __ \\ ",
printf("\n"); "\x1b[1m | / | ",
printf("\x1b[1m ||||||||| |||| %s\n", os); "\x1b[1m | \\___- ",
printf("\x1b[1m ||||||||| |||| %s\n", get_kernel(kern_name)); "\x1b[1m -_ ",
printf("\x1b[1m |||| |||| %s\n", get_uptime(uptime)); "\x1b[1m --_ ",
printf("\x1b[1m |||| |||| |||| %s\n", get_packages(package_count, sys)); "\x1b[1m "
printf("\x1b[1m |||| |||| |||| %s\n", cpu_name); },
printf("\x1b[1m |||| |||| |||| %s\n", gpu);
printf("\x1b[1m |||| |||| |||| %s\n", get_RAM(ram_info));
printf("\n\n"); { "\x1b[1m _ ",
"\x1b[1m ---(_) ",
break; "\x1b[1m _/ --- \\ ",
"\x1b[1m (_) | | ",
case 'v': "\x1b[1m \\ --- / ",
printf("\n"); "\x1b[1m ---(_) ",
printf("\x1b[1m | | | | (_)(_) | | %s\n", os); "\x1b[1m "
printf("\x1b[1m | | | | ___ _ ___ _____ __| | __ _ %s\n", get_kernel(kern_name)); },
printf("\x1b[1m | | | |/ _ \\| || \\ \\ / / _ \\ / _` |/ _` | %s\n", get_uptime(uptime));
printf("\x1b[1m \\ \\_/ / (_) | || |\\ V / (_) | (_| | (_| | %s\n", get_packages(package_count, sys));
printf("\x1b[1m \\___/ \\___/| || | \\_/ \\___/ \\__,_|\\__,_| %s\n", cpu_name); { "\x1b[1m /\\ ",
printf("\x1b[1m _/ |/ | %s\n", gpu); "\x1b[1m / \\ ",
printf("\x1b[1m |__/__/ %s\n", get_RAM(ram_info)); "\x1b[1m / /\\ \\ ",
printf("\n\n"); "\x1b[1m / / \\ \\ ",
"\x1b[1m / / \\ \\ ",
break; "\x1b[1m / / _____\\ \\ ",
"\x1b[1m /_/ \\`----.\\_\\ "
case 'o': },
printf("\n");
printf("\x1b[1m %s\n", os); { "\x1b[1m ||||||||| |||| ",
printf("\x1b[1m ______ _____ ________ ___ %s\n", get_kernel(kern_name)); "\x1b[1m ||||||||| |||| ",
printf("\x1b[1m | _ \\ _ | _ | \\/ | %s\n", get_uptime(uptime)); "\x1b[1m |||| |||| ",
printf("\x1b[1m | | | | | | | | | | . . | %s\n", get_packages(package_count, sys)); "\x1b[1m |||| |||| |||| ",
printf("\x1b[1m | | | | | | | | | | |\\/| | %s\n", cpu_name); "\x1b[1m |||| |||| |||| ",
printf("\x1b[1m | |/ /\\ \\_/ | \\_/ / | | | %s\n", gpu); "\x1b[1m |||| |||| |||| ",
printf("\x1b[1m |___/ \\___/ \\___/\\_| |_/ %s\n", get_RAM(ram_info)); "\x1b[1m |||| |||| |||| "
printf("\n\n"); }
break;
default: };
printf("\n\n ERROR : Unsupported system\n\n");
exit(EXIT_FAILURE);
}
free(uptime);
free(ram_info);
free(kern_name);
free(package_count);
}