2024-06-17 22:41:46 +09:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "src/user.h"
|
|
|
|
#include "src/os.h"
|
|
|
|
#if defined(__linux__)
|
|
|
|
#include "src/distro.h"
|
|
|
|
#endif
|
2024-06-18 14:06:43 +09:00
|
|
|
#include "src/host.h"
|
|
|
|
#include "src/uptime.h"
|
|
|
|
#if defined(__OpenBSD__)
|
|
|
|
#include "src/recording.h"
|
|
|
|
#endif
|
2024-06-18 19:12:24 +09:00
|
|
|
#include "src/packages.h"
|
2024-06-18 13:39:02 +09:00
|
|
|
#include "src/cpu.h"
|
2024-06-18 19:23:34 +09:00
|
|
|
#include "src/gpu.h"
|
2024-06-18 00:16:45 +09:00
|
|
|
#include "src/memory.h"
|
2024-06-17 22:41:46 +09:00
|
|
|
|
|
|
|
const char *sofname = "farfetch";
|
|
|
|
const char *version = "0.0.1";
|
|
|
|
|
2024-06-18 17:48:32 +09:00
|
|
|
int main(int argc, char *argv[]) {
|
2024-06-18 15:59:14 +09:00
|
|
|
int lc = 0;
|
2024-06-18 17:48:32 +09:00
|
|
|
int issmall = 0;
|
|
|
|
if (argc == 2 && strncmp(argv[1], "-s", strlen("-s")) == 0) {
|
|
|
|
issmall = 1;
|
|
|
|
}
|
2024-06-18 15:25:34 +09:00
|
|
|
#if defined(__OpenBSD__)
|
|
|
|
#include "src/logo/openbsd.h"
|
2024-06-19 19:38:19 +09:00
|
|
|
getOS();
|
2024-06-18 15:59:14 +09:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
#include "src/logo/netbsd.h"
|
2024-06-19 19:38:19 +09:00
|
|
|
getOS();
|
2024-06-18 15:59:14 +09:00
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
#include "src/logo/freebsd.h"
|
2024-06-19 19:38:19 +09:00
|
|
|
getOS();
|
2024-06-18 22:04:27 +09:00
|
|
|
#elif defined(__linux__)
|
2024-06-19 19:57:33 +09:00
|
|
|
get_distro();
|
2024-06-18 22:04:27 +09:00
|
|
|
#include "src/logo/linux.h"
|
2024-06-19 19:38:19 +09:00
|
|
|
getDistro(distroname);
|
2024-06-18 15:25:34 +09:00
|
|
|
#else
|
2024-06-19 23:30:10 +09:00
|
|
|
const char *color = MAGENTA;
|
|
|
|
const char *titlecolor = MAGENTA;
|
|
|
|
size_t logosize = 11;
|
2024-06-18 15:25:34 +09:00
|
|
|
#define COLOR "\e[1;30m"
|
|
|
|
#define RESET "\e[0m"
|
|
|
|
char *LOGO[] = {
|
|
|
|
" ⢀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣠⠾⠛⠶⣄⢀⣠⣤⠴⢦⡀⠀⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⢠⡿⠉⠉⠉⠛⠶⠶⠖⠒⠒⣾⠋⠀⢀⣀⣙⣯⡁⠀⠀⠀⣿⠀⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⡏⠀⠀⢯⣼⠋⠉⠙⢶⠞⠛⠻⣆⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⢸⣧⠆⠀⠀⠀⠀⠀⠀⠀⠀⠻⣦⣤⡤⢿⡀⠀⢀⣼⣷⠀⠀⣽⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⢏⡉⠁⣠⡾⣇⠀⠀⠀",
|
|
|
|
"⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠋⠉⠀⢻⡀⠀⠀",
|
|
|
|
"⣀⣠⣼⣧⣤⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠐⠖⢻⡟⠓⠒",
|
|
|
|
"⠀⠀⠈⣷⣀⡀⠀⠘⠿⠇⠀⠀⠀⢀⣀⣀⠀⠀⠀⠀⠿⠟⠀⠀⠀⠲⣾⠦⢤⠀",
|
|
|
|
"⠀⠀⠋⠙⣧⣀⡀⠀⠀⠀⠀⠀⠀⠘⠦⠼⠃⠀⠀⠀⠀⠀⠀⠀⢤⣼⣏⠀⠀⠀",
|
|
|
|
"⠀⠀⢀⠴⠚⠻⢧⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⠞⠉⠉⠓⠀⠀",
|
2024-06-18 19:28:14 +09:00
|
|
|
"⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠛⠶⠶⠶⣶⣤⣴⡶⠶⠶⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀"
|
|
|
|
};
|
|
|
|
char *LOGO_SMALL[] = {
|
|
|
|
" ⢀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣠⠾⠛⠶⣄⢀⣠⣤⠴⢦⡀⠀⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⢠⡿⠉⠉⠉⠛⠶⠶⠖⠒⠒⣾⠋⠀⢀⣀⣙⣯⡁⠀⠀⠀⣿⠀⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⡏⠀⠀⢯⣼⠋⠉⠙⢶⠞⠛⠻⣆⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⢸⣧⠆⠀⠀⠀⠀⠀⠀⠀⠀⠻⣦⣤⡤⢿⡀⠀⢀⣼⣷⠀⠀⣽⠀⠀⠀",
|
|
|
|
"⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⢏⡉⠁⣠⡾⣇⠀⠀⠀",
|
|
|
|
"⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠋⠉⠀⢻⡀⠀⠀",
|
|
|
|
"⣀⣠⣼⣧⣤⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠐⠖⢻⡟⠓⠒",
|
|
|
|
"⠀⠀⠈⣷⣀⡀⠀⠘⠿⠇⠀⠀⠀⢀⣀⣀⠀⠀⠀⠀⠿⠟⠀⠀⠀⠲⣾⠦⢤⠀",
|
|
|
|
"⠀⠀⠋⠙⣧⣀⡀⠀⠀⠀⠀⠀⠀⠘⠦⠼⠃⠀⠀⠀⠀⠀⠀⠀⢤⣼⣏⠀⠀⠀",
|
|
|
|
"⠀⠀⢀⠴⠚⠻⢧⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⠞⠉⠉⠓⠀⠀",
|
2024-06-18 15:25:34 +09:00
|
|
|
"⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠛⠶⠶⠶⣶⣤⣴⡶⠶⠶⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀"
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2024-06-19 23:30:10 +09:00
|
|
|
size_t ls = logosize <= MIN_SIZE ? MIN_SIZE : logosize;
|
2024-06-18 17:48:32 +09:00
|
|
|
if (issmall) {
|
|
|
|
size_t ne = sizeof(LOGO_SMALL) / sizeof(LOGO_SMALL[0]);
|
|
|
|
for (size_t i = 0; i < ne; i++) {
|
|
|
|
LOGO[i] = LOGO_SMALL[i];
|
|
|
|
}
|
2024-06-19 22:13:47 +09:00
|
|
|
ls = ne >= MIN_SIZE ? MIN_SIZE : ne;
|
2024-06-18 17:48:32 +09:00
|
|
|
}
|
|
|
|
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s", titlecolor);
|
2024-06-17 22:41:46 +09:00
|
|
|
display_user_name();
|
2024-06-18 15:25:34 +09:00
|
|
|
printf(RESET);
|
2024-06-17 22:41:46 +09:00
|
|
|
printf("@");
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s", titlecolor);
|
2024-06-17 22:41:46 +09:00
|
|
|
display_user_host();
|
2024-06-18 15:25:34 +09:00
|
|
|
printf(RESET);
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-18 00:44:43 +09:00
|
|
|
printf("------------------\n");
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-17 22:41:46 +09:00
|
|
|
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "OS", ": ");
|
2024-06-17 22:41:46 +09:00
|
|
|
display_os_name();
|
|
|
|
printf(" ");
|
|
|
|
display_os_vers();
|
|
|
|
printf(" ");
|
|
|
|
display_os_arch();
|
|
|
|
printf("\n");
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-17 22:41:46 +09:00
|
|
|
|
|
|
|
#if defined(__linux__)
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:57:33 +09:00
|
|
|
printf("%s%s%s"RESET, color, "Distro", ": ");
|
|
|
|
printf("%s\n", display_distro());
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-17 22:41:46 +09:00
|
|
|
#endif
|
|
|
|
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "Host", ": ");
|
2024-06-18 00:16:45 +09:00
|
|
|
display_host_model();
|
|
|
|
printf("\n");
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-18 00:16:45 +09:00
|
|
|
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "Uptime", ": ");
|
2024-06-18 13:39:02 +09:00
|
|
|
display_days();
|
|
|
|
printf(", ");
|
|
|
|
display_time();
|
|
|
|
printf("\n");
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-18 13:39:02 +09:00
|
|
|
|
2024-06-18 14:06:43 +09:00
|
|
|
#if defined(__OpenBSD__)
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "Recording", ": ");
|
2024-06-18 15:25:34 +09:00
|
|
|
printf("audio = ");
|
2024-06-18 14:06:43 +09:00
|
|
|
display_recording_audio();
|
|
|
|
printf(", video = ");
|
|
|
|
display_recording_video();
|
|
|
|
printf("\n");
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-18 14:06:43 +09:00
|
|
|
#endif
|
|
|
|
|
2024-06-18 19:12:24 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "Packages", ": ");
|
2024-06-18 19:12:24 +09:00
|
|
|
display_packages();
|
|
|
|
printf("\n");
|
|
|
|
lc++;
|
|
|
|
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "CPU", ": ");
|
2024-06-18 13:39:02 +09:00
|
|
|
display_cpu();
|
|
|
|
printf("\n");
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-18 13:39:02 +09:00
|
|
|
|
2024-06-19 15:44:06 +09:00
|
|
|
if (display_gpu()) {
|
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "GPU", ": ");
|
2024-06-19 15:49:59 +09:00
|
|
|
printf("%s\n", display_gpu());
|
2024-06-19 15:44:06 +09:00
|
|
|
lc++;
|
|
|
|
}
|
2024-06-18 19:23:34 +09:00
|
|
|
|
2024-06-18 15:59:14 +09:00
|
|
|
printf("%s ", LOGO[lc]);
|
2024-06-19 19:38:19 +09:00
|
|
|
printf("%s%s%s"RESET, color, "Memory", ": ");
|
2024-06-18 00:16:45 +09:00
|
|
|
display_memory();
|
|
|
|
printf("\n");
|
2024-06-18 15:59:14 +09:00
|
|
|
lc++;
|
2024-06-18 00:16:45 +09:00
|
|
|
|
2024-06-18 17:48:32 +09:00
|
|
|
for (size_t i = lc; i < ls; i++) {
|
2024-06-18 15:25:34 +09:00
|
|
|
printf("%s\n", LOGO[i]);
|
|
|
|
}
|
|
|
|
|
2024-06-17 22:41:46 +09:00
|
|
|
// TODO:
|
|
|
|
// * ロゴ
|
|
|
|
// * パッケージ
|
|
|
|
// * libc
|
|
|
|
// * シェル
|
|
|
|
// * 解像度
|
|
|
|
// * 端末
|
|
|
|
// * GPU
|
|
|
|
// * ストレージ
|
2024-06-19 19:38:19 +09:00
|
|
|
|
2024-06-17 22:41:46 +09:00
|
|
|
return 0;
|
|
|
|
}
|