1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
#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
#include "src/cpu.h"
#include "src/memory.h"
const char *sofname = "farfetch";
const char *version = "0.0.1";
int main(int argc, char *argv[]) {
int lc = 0;
int issmall = 0;
if (argc == 2 && strncmp(argv[1], "-s", strlen("-s")) == 0) {
issmall = 1;
}
#if defined(__OpenBSD__)
#include "src/logo/openbsd.h"
#elif defined(__NetBSD__)
#include "src/logo/netbsd.h"
#elif defined(__FreeBSD__)
#include "src/logo/freebsd.h"
#else
#define COLOR "\e[1;30m"
#define RESET "\e[0m"
char *LOGO[] = {
" ⢀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣠⠾⠛⠶⣄⢀⣠⣤⠴⢦⡀⠀⠀⠀⠀",
"⠀⠀⠀⢠⡿⠉⠉⠉⠛⠶⠶⠖⠒⠒⣾⠋⠀⢀⣀⣙⣯⡁⠀⠀⠀⣿⠀⠀⠀⠀",
"⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⡏⠀⠀⢯⣼⠋⠉⠙⢶⠞⠛⠻⣆⠀⠀⠀",
"⠀⠀⠀⢸⣧⠆⠀⠀⠀⠀⠀⠀⠀⠀⠻⣦⣤⡤⢿⡀⠀⢀⣼⣷⠀⠀⣽⠀⠀⠀",
"⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⢏⡉⠁⣠⡾⣇⠀⠀⠀",
"⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠋⠉⠀⢻⡀⠀⠀",
"⣀⣠⣼⣧⣤⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠐⠖⢻⡟⠓⠒",
"⠀⠀⠈⣷⣀⡀⠀⠘⠿⠇⠀⠀⠀⢀⣀⣀⠀⠀⠀⠀⠿⠟⠀⠀⠀⠲⣾⠦⢤⠀",
"⠀⠀⠋⠙⣧⣀⡀⠀⠀⠀⠀⠀⠀⠘⠦⠼⠃⠀⠀⠀⠀⠀⠀⠀⢤⣼⣏⠀⠀⠀",
"⠀⠀⢀⠴⠚⠻⢧⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⠞⠉⠉⠓⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠛⠶⠶⠶⣶⣤⣴⡶⠶⠶⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀"
};
#endif
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;
}
printf("%s ", LOGO[lc]);
printf(COLOR);
display_user_name();
printf(RESET);
printf("@");
printf(COLOR);
display_user_host();
printf(RESET);
lc++;
printf("%s ", LOGO[lc]);
printf("------------------\n");
lc++;
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "OS", ": ");
display_os_name();
printf(" ");
display_os_vers();
printf(" ");
display_os_arch();
printf("\n");
lc++;
#if defined(__linux__)
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "Distro", ": ");
display_distro();
printf("\n");
lc++;
#endif
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "Host", ": ");
display_host_model();
printf("\n");
lc++;
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "Uptime", ": ");
display_days();
printf(", ");
display_time();
printf("\n");
lc++;
#if defined(__OpenBSD__)
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "Recording", ": ");
printf("audio = ");
display_recording_audio();
printf(", video = ");
display_recording_video();
printf("\n");
lc++;
#endif
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "CPU", ": ");
display_cpu();
printf("\n");
lc++;
printf("%s ", LOGO[lc]);
printf(COLOR"%s%s"RESET, "Memory", ": ");
display_memory();
printf("\n");
lc++;
for (size_t i = lc; i < ls; i++) {
printf("%s\n", LOGO[i]);
}
// TODO:
// * ロゴ
// * パッケージ
// * libc
// * シェル
// * 解像度
// * 端末
// * GPU
// * ストレージ
return 0;
}
|