farfetch/main.c

150 行
3.6 KiB
C
Raw 通常表示 履歴

2024-06-17 22:41:46 +09:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "src/user.h"
#include "src/os.h"
#if defined(__linux__)
#include "src/distro.h"
#endif
#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 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-18 15:59:14 +09:00
#elif defined(__NetBSD__)
#include "src/logo/netbsd.h"
#elif defined(__FreeBSD__)
#include "src/logo/freebsd.h"
2024-06-18 15:25:34 +09:00
#else
#define COLOR "\e[1;30m"
#define RESET "\e[0m"
char *LOGO[] = {
" ⢀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣠⠾⠛⠶⣄⢀⣠⣤⠴⢦⡀⠀⠀⠀⠀",
"⠀⠀⠀⢠⡿⠉⠉⠉⠛⠶⠶⠖⠒⠒⣾⠋⠀⢀⣀⣙⣯⡁⠀⠀⠀⣿⠀⠀⠀⠀",
"⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⡏⠀⠀⢯⣼⠋⠉⠙⢶⠞⠛⠻⣆⠀⠀⠀",
"⠀⠀⠀⢸⣧⠆⠀⠀⠀⠀⠀⠀⠀⠀⠻⣦⣤⡤⢿⡀⠀⢀⣼⣷⠀⠀⣽⠀⠀⠀",
"⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⢏⡉⠁⣠⡾⣇⠀⠀⠀",
"⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠋⠉⠀⢻⡀⠀⠀",
"⣀⣠⣼⣧⣤⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠐⠖⢻⡟⠓⠒",
"⠀⠀⠈⣷⣀⡀⠀⠘⠿⠇⠀⠀⠀⢀⣀⣀⠀⠀⠀⠀⠿⠟⠀⠀⠀⠲⣾⠦⢤⠀",
"⠀⠀⠋⠙⣧⣀⡀⠀⠀⠀⠀⠀⠀⠘⠦⠼⠃⠀⠀⠀⠀⠀⠀⠀⢤⣼⣏⠀⠀⠀",
"⠀⠀⢀⠴⠚⠻⢧⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⠞⠉⠉⠓⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠛⠶⠶⠶⣶⣤⣴⡶⠶⠶⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀"
};
#endif
2024-06-18 17:48:32 +09:00
size_t ls = sizeof(LOGO) / sizeof(LOGO[0]);
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];
}
ls = ne;
}
2024-06-18 15:59:14 +09:00
printf("%s ", LOGO[lc]);
2024-06-18 15:25:34 +09:00
printf(COLOR);
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-18 15:25:34 +09:00
printf(COLOR);
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-18 15:25:34 +09:00
printf(COLOR"%s%s"RESET, "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-18 15:25:34 +09:00
printf(COLOR"%s%s"RESET, "Distro", ": ");
2024-06-17 22:41:46 +09:00
display_distro();
printf("\n");
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-18 15:25:34 +09:00
printf(COLOR"%s%s"RESET, "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-18 15:25:34 +09:00
printf(COLOR"%s%s"RESET, "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
#if defined(__OpenBSD__)
2024-06-18 15:59:14 +09:00
printf("%s ", LOGO[lc]);
2024-06-18 15:25:34 +09:00
printf(COLOR"%s%s"RESET, "Recording", ": ");
printf("audio = ");
display_recording_audio();
printf(", video = ");
display_recording_video();
printf("\n");
2024-06-18 15:59:14 +09:00
lc++;
#endif
2024-06-18 19:12:24 +09:00
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "Packages", ": ");
display_packages();
printf("\n");
lc++;
2024-06-18 15:59:14 +09:00
printf("%s ", LOGO[lc]);
2024-06-18 15:25:34 +09:00
printf(COLOR"%s%s"RESET, "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-18 15:59:14 +09:00
printf("%s ", LOGO[lc]);
2024-06-18 15:25:34 +09:00
printf(COLOR"%s%s"RESET, "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
// * ストレージ
return 0;
}