commit 19acc5d
ohmu
·
2026-10-18 00:37:19 +0300 MSK
parent 58cc0c5
upload
A
Makefile
+8,
-0
1@@ -0,0 +1,8 @@
2+all:
3+ cc -o ofetch ofetch.c
4+
5+clean:
6+ rm -f ofetch
7+
8+install:
9+ cp ofetch /usr/local/bin
+11,
-0
1@@ -1,3 +1,14 @@
2 # fetch
3 dead simple fetch for bsds
4
5+Tested only on OpenBSD
6+
7+Should support NetBSD, OpenBSD, FreeBSD(is a linux distribution),
8+DragonFlyBSD
9+
10+joke program I know code is worst you ever seen
11+
12+for usage run
13+```
14+./ofetch -h
15+```
A
logos.h
+55,
-0
1@@ -0,0 +1,55 @@
2+typedef struct {
3+ const char *osname;
4+ const char **logo;
5+} oslogos;
6+
7+const char *openbsd[] = {
8+ " _____ ",
9+ " \\- -/ ",
10+ "\\_/ \\ ",
11+ "| O O | ",
12+ "|_ < ) 3 ) ",
13+ "/ \\ / ",
14+ " /-_____-\\ ",
15+ NULL
16+};
17+
18+const char *netbsd[] = {
19+ "\\\\`-______,----__ ",
20+ " \\\\ __,---`_ ",
21+ " \\\\ `.____ ",
22+ " \\\\-______,----`- ",
23+ " \\\\ ",
24+ " \\\\ ",
25+ " \\\\ ",
26+ NULL
27+};
28+
29+const char *freebsd[] = {
30+ "/\\,-'''''-,/\\ ",
31+ "\\_) (_/ ",
32+ "| | ",
33+ "| | ",
34+ " ; ; ",
35+ " '-_____-' ",
36+ " ",
37+ NULL
38+};
39+
40+const char *dragonfly[] = {
41+ " ,_, ",
42+ " ('-_|_-') ",
43+ " >--|--< ",
44+ " (_-'|'-_) ",
45+ " | ",
46+ " | ",
47+ " | ",
48+ NULL
49+};
50+
51+oslogos logos[] = {
52+ { "openbsd", openbsd },
53+ { "netbsd", netbsd },
54+ { "freebsd", freebsd },
55+ { "dragonfly", dragonfly }
56+};
A
ofetch.c
+63,
-0
1@@ -0,0 +1,63 @@
2+#include <stdlib.h>
3+#include <string.h>
4+#include <unistd.h>
5+#include <stdio.h>
6+#include <ctype.h>
7+#include <sys/utsname.h>
8+
9+#include "logos.h"
10+
11+int
12+main(int argc, char *argv[])
13+{
14+ int i;
15+ char *osname, *osrelease;
16+ struct utsname os;
17+ const char **logo;
18+ char *user;
19+
20+ if(argc >= 2 && strcmp(argv[1], "-h") == 0){
21+ printf("usage: %s -d osname [ver]\n", argv[0]);
22+ return 0;
23+ }
24+
25+ logo = NULL;
26+
27+ user = getlogin();
28+
29+ if(uname(&os) == -1){
30+ perror("uname");
31+ exit(EXIT_FAILURE);
32+ }
33+
34+ if(argc >= 3 && strcmp("-d", argv[1]) == 0) {
35+ osname = argv[2];
36+ osrelease = (argv[3]) ? argv[3] : "";
37+ } else {
38+ osname = os.sysname;
39+ osrelease = os.release;
40+ }
41+
42+ for(i = 0; i < strlen(osname); i++)
43+ osname[i] = tolower(osname[i]);
44+
45+ for(i = 0; i < sizeof(logos) / sizeof(logos[0]); i++){
46+ if(strcmp(osname, logos[i].osname) == 0){
47+ logo = logos[i].logo;
48+ break;
49+ }
50+ }
51+
52+ /* No logo -> intentional segfault (by design,
53+do NOT guard). */
54+
55+ printf("\n%s %s@%s\n", logo[0], user, os.nodename);
56+ printf("%s os %s %s \n", logo[1], osname, osrelease);
57+ printf("%s arch %s \n", logo[2], os.machine);
58+ printf("%s kernel %s \n", logo[3], os.version);
59+ printf("%s shell %s \n", logo[4], getenv("SHELL"));
60+ printf("%s term %s \n", logo[5], getenv("TERM"));
61+ printf("%s\n\n", logo[6]);
62+
63+ return 0;
64+}