forked from nakidai/mycfetch
Compare commits
17 Commits
Author | SHA1 | Date |
---|---|---|
Nakidai | a576f988c5 | |
Nakidai | 20a6f94a8e | |
Nakidai | 412e71d684 | |
Nakidai | 48a0b477ee | |
Nakidai | 09c633e8ac | |
Nakidai | e3f577fe3d | |
Nakidai | 98d17bb950 | |
Nakidai | 37f2756ad0 | |
Nakidai | 89cdcd4361 | |
Nakidai | aa9e2561a1 | |
Nakidai | d7560a6f4e | |
Nakidai | 2957c35155 | |
Nakidai | 9d50bb4071 | |
Nakidai | c120ca4e5a | |
Nakidai | cb0f4619f4 | |
Nakidai | 56aeea219c | |
Nakidai | 806f176ab0 |
|
@ -1 +1,3 @@
|
|||
mycfetch
|
||||
compile_commands.json
|
||||
.cache/
|
||||
|
|
22
Makefile
22
Makefile
|
@ -1,15 +1,21 @@
|
|||
CC := cc
|
||||
CFLAGS :=
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= ${PREFIX}/bin
|
||||
MANDIR ?= ${PREFIX}/share/man
|
||||
|
||||
all: mycfetch
|
||||
|
||||
mycfetch: main.c config.h
|
||||
$(CC) main.c -o mycfetch $(CFLAGS)
|
||||
|
||||
install: mycfetch
|
||||
cp mycfetch /usr/bin/mycfetch
|
||||
mycfetch: config.h defs.h
|
||||
|
||||
clean:
|
||||
rm mycfetch
|
||||
rm -f mycfetch
|
||||
|
||||
install: mycfetch mycfetch.1
|
||||
install -d ${DESTDIR}${BINDIR} ${DESTDIR}${MANDIR}/man1
|
||||
install mycfetch ${DESTDIR}${BINDIR}
|
||||
install -m 644 mycfetch.1 ${DESTDIR}${MANDIR}/man1
|
||||
|
||||
uninstall:
|
||||
rm -f ${DESTDIR}${BINDIR}/mycfetch
|
||||
rm -f ${DESTDIR}${MANDIR}/man1/mycfetch.1
|
||||
|
||||
.PHONY: all install clean
|
||||
|
|
28
README.md
28
README.md
|
@ -1,3 +1,29 @@
|
|||
# mycfetch
|
||||
|
||||
Simle neofetch.
|
||||
Simple fetch
|
||||
|
||||
```
|
||||
$ mycfetch cat
|
||||
╱|、 naki@nakidai
|
||||
(˚ˎ。7 --
|
||||
| 、˜〵 Linux 6.10.0-rc3-ga3e18a540541
|
||||
じしˍ,)ノ Up 2 hours, 20 minutes
|
||||
```
|
||||
|
||||
Usage
|
||||
--
|
||||
Use first argument as art name. If no arguments given or name is invalid,
|
||||
mycfetch will use first one from the `arts`
|
||||
|
||||
For convenience, you can set alias for needed art
|
||||
|
||||
Install
|
||||
--
|
||||
mycfetch is available on [AUR](https://aur.archlinux.org/packages/mycfetch)
|
||||
|
||||
List of arts
|
||||
--
|
||||
- `cat`
|
||||
- `freebsd`
|
||||
- `gentoo`
|
||||
- `arch`
|
||||
|
|
67
config.h
67
config.h
|
@ -1,29 +1,44 @@
|
|||
const int max_username_length = 128;
|
||||
const int max_hostname_length = 128;
|
||||
const int max_uptime_length = 40;
|
||||
#include "defs.h"
|
||||
|
||||
char *art[] = {
|
||||
// FreeBSD
|
||||
"\033[31m_ _\033[0m",
|
||||
"\033[31m\\‾‾‾‾/\033[0m",
|
||||
"\033[31m|^ww^|\033[0m",
|
||||
"\033[31m\\____/\033[0m"
|
||||
static const int max_username_length = 128;
|
||||
static const int max_hostname_length = 128;
|
||||
static const int max_uptime_length = 40;
|
||||
|
||||
// Gentoo
|
||||
// "\x1B[38;5;135m /‾\\",
|
||||
// "\x1B[38;5;135m( \x1B[38;5;183mo \x1B[38;5;135m\\",
|
||||
// "\x1B[38;5;135m/ /",
|
||||
// "\x1B[38;5;135m\\__/"
|
||||
|
||||
// Arch
|
||||
// " /\\ ",
|
||||
// " /\\ \\ ",
|
||||
// " / \\ ",
|
||||
// "/__/\\__\\"
|
||||
|
||||
// Just cute cat
|
||||
// " ╱|、 ",
|
||||
// "(˚ˎ。7 ",
|
||||
// " |、˜〵 ",
|
||||
// "じしˍ,)ノ"
|
||||
static struct art_entry arts[] = {
|
||||
{
|
||||
"cat",
|
||||
{
|
||||
" ╱|、 ",
|
||||
"(˚ˎ。7 ",
|
||||
"| 、˜〵 ",
|
||||
"じしˍ,)ノ"
|
||||
}
|
||||
},
|
||||
{
|
||||
"freebsd",
|
||||
{
|
||||
"\033[31m_ _\033[0m",
|
||||
"\033[31m\\‾‾‾‾/\033[0m",
|
||||
"\033[31m|^vv^|\033[0m",
|
||||
"\033[31m\\____/\033[0m"
|
||||
}
|
||||
},
|
||||
{
|
||||
"gentoo",
|
||||
{
|
||||
"\033[35m /‾\\ \033[0m",
|
||||
"\033[35m( \033[37mo \033[35m\\\033[0m",
|
||||
"\033[35m/ /\033[0m",
|
||||
"\033[35m\\__/ \033[0m"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arch",
|
||||
{
|
||||
"\033[34m /\\ \033[0m",
|
||||
"\033[34m /\\ \\ \033[0m",
|
||||
"\033[34m / \\ \033[0m",
|
||||
"\033[34m/__/\\__\\\033[0m"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef __DEFS_H__
|
||||
#define __DEFS_H__
|
||||
|
||||
struct art_entry
|
||||
{
|
||||
char *name;
|
||||
char *art[4];
|
||||
};
|
||||
|
||||
#endif /* __DEFS_H__ */
|
|
@ -0,0 +1,62 @@
|
|||
.Dd August 23, 2024
|
||||
.Dt MYCFETCH 1
|
||||
.Os
|
||||
.
|
||||
.Sh NAME
|
||||
.Nm mycfetch
|
||||
.Nd System info fetcher
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Ar artname
|
||||
.
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
shows you some information about computer. On the left you will see some cute
|
||||
ascii art, on the right -
|
||||
.Ql user@host ,
|
||||
kernel name and version, and current uptime.
|
||||
.Pp
|
||||
.
|
||||
Arts are added to
|
||||
.Nm
|
||||
through
|
||||
.Ql config.h
|
||||
file.
|
||||
.
|
||||
.Bl -tag -width Ds
|
||||
.It Ar artname
|
||||
Name of the art to show on the left.
|
||||
.
|
||||
.Sh EXIT STATUS
|
||||
.Nm
|
||||
returns 0 if done without errors or 69 if art is not found.
|
||||
.
|
||||
.Sh EXAMPLES
|
||||
For example,
|
||||
.Bd -literal -offset indent
|
||||
$ mycfetch cat
|
||||
.Ed
|
||||
Will show cat on the left with some system info.
|
||||
.Ql cat
|
||||
can be ommited because it's the first entry in the config.
|
||||
.Bd -literal -offset indent
|
||||
╱|、 naki@nakidai
|
||||
(˚ˎ。7 --
|
||||
| 、˜〵 Linux 6.10.4-arch2-1
|
||||
じしˍ,)ノ Up 1 days, 5 hours, 23 minutes
|
||||
.Ed
|
||||
.
|
||||
.Sh STANDARDS
|
||||
.Nm
|
||||
is
|
||||
.St -p1003.1-2004
|
||||
compatible, while also uses
|
||||
.Fn "int clock_gettime" "clockid_t" "struct timespec *"
|
||||
from
|
||||
.St -p1003.1b
|
||||
.Sy TMR
|
||||
extension.
|
||||
.
|
||||
.Sh AUTHORS
|
||||
.An Nakidai Perumenei Aq Mt plaza521@inbox.ru
|
||||
.
|
|
@ -1,9 +1,14 @@
|
|||
#define _POSIX_C_SOURCE 200112L
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "defs.h"
|
||||
|
||||
void getuptime(char *buffer, int max_length)
|
||||
{
|
||||
|
@ -26,8 +31,18 @@ void getuptime(char *buffer, int max_length)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char **art = arts[0].art, *name = argv[1];
|
||||
int ret = 0;
|
||||
if (name)
|
||||
{
|
||||
bool found = false;
|
||||
for (int i = 0; i < sizeof(arts) / sizeof(*arts); ++i)
|
||||
if (!strcmp(arts[i].name, name))
|
||||
{ art = arts[i].art; found = true; break; }
|
||||
if (!found) ret = 69;
|
||||
}
|
||||
|
||||
struct utsname uname_buf;
|
||||
struct timespec uptime_buf;
|
||||
char hostname[max_hostname_length];
|
||||
char username[max_username_length];
|
||||
char uptime[max_uptime_length];
|
||||
|
@ -35,12 +50,17 @@ int main(int argc, char **argv)
|
|||
gethostname(hostname, max_hostname_length);
|
||||
getlogin_r(username, max_username_length);
|
||||
getuptime(uptime, max_uptime_length);
|
||||
|
||||
uname(&uname_buf);
|
||||
printf("%s %s@%s\n", art[0], username, hostname);
|
||||
printf("%s --\n", art[1]);
|
||||
printf("%s %s %s\n", art[2], uname_buf.sysname, uname_buf.release);
|
||||
printf("%s %s\n", art[3], uptime);
|
||||
// #include "order.c"
|
||||
return 0;
|
||||
|
||||
printf(
|
||||
"%s %s@%s\n"
|
||||
"%s --\n"
|
||||
"%s %s %s\n"
|
||||
"%s %s\n",
|
||||
art[0], username, hostname,
|
||||
art[1],
|
||||
art[2], uname_buf.sysname, uname_buf.release,
|
||||
art[3], uptime
|
||||
);
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue