Compare commits

...

12 Commits

Author SHA1 Message Date
Nakidai a576f988c5
Fix typo 2024-08-23 12:00:48 +03:00
Nakidai 20a6f94a8e
Add manual
Also add mycfetch.1 to install
2024-08-23 10:10:20 +03:00
Nakidai 412e71d684
Some changes in code
- Define about POSIX
- Return 69 if no art with specified name found
2024-08-23 10:01:43 +03:00
Nakidai 48a0b477ee
Update README.md
- Add example of output
- Edit description of the behavior of the art selection algorithm
2024-07-04 03:11:41 +03:00
Nakidai 09c633e8ac
Rewrite code a little
- Make variables declared in header static
- Simplify art selection, now ignore invalid argument count or art name
- Remove `die` function (was needed by previous art selection)
2024-07-04 02:59:09 +03:00
Nakidai e3f577fe3d Fix README.md 2024-02-19 23:50:42 +03:00
Nakidai 98d17bb950 Edit README.md 2024-02-19 23:50:10 +03:00
Nakidai 37f2756ad0 This thing wasn't working 2024-02-19 18:45:43 +03:00
Nakidai 89cdcd4361 Fix arch art 2024-02-19 18:45:21 +03:00
Nakidai aa9e2561a1 Update Makfile 2024-02-19 18:26:15 +03:00
Nakidai d7560a6f4e Add colors for arch and gentoo arts 2024-02-19 18:24:33 +03:00
Nakidai 2957c35155 Edit README.md 2023-12-16 01:52:12 +03:00
6 changed files with 127 additions and 45 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
mycfetch mycfetch
compile_commands.json
.cache/

View File

@ -1,11 +1,21 @@
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
MANDIR ?= ${PREFIX}/share/man
all: mycfetch all: mycfetch
install: mycfetch mycfetch: config.h defs.h
install -m 555 mycfetch $(PREFIX)/bin/
clean: clean:
rm -f 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 .PHONY: all install clean

View File

@ -1,11 +1,25 @@
# mycfetch # mycfetch
Simple neofetch. Simple fetch
```
$ mycfetch cat
|、 naki@nakidai
(˚ˎ。7 --
| 、˜〵 Linux 6.10.0-rc3-ga3e18a540541
じしˍ,) Up 2 hours, 20 minutes
```
Usage Usage
-- --
Use argument to select art. If not argument provided, mycfetch uses first entry in arts list. Use first argument as art name. If no arguments given or name is invalid,
For convenience, you can set alias for needed art. 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 List of arts
-- --

View File

@ -1,10 +1,10 @@
#include "defs.h" #include "defs.h"
const int max_username_length = 128; static const int max_username_length = 128;
const int max_hostname_length = 128; static const int max_hostname_length = 128;
const int max_uptime_length = 40; static const int max_uptime_length = 40;
struct art_entry arts[] = { static struct art_entry arts[] = {
{ {
"cat", "cat",
{ {
@ -26,19 +26,19 @@ struct art_entry arts[] = {
{ {
"gentoo", "gentoo",
{ {
" /‾\\ ", "\033[35m /‾\\ \033[0m",
"( o \\", "\033[35m( \033[37mo \033[35m\\\033[0m",
"/ /", "\033[35m/ /\033[0m",
"\\__/ " "\033[35m\\__/ \033[0m"
} }
}, },
{ {
"arch", "arch",
{ {
" /\\ ", "\033[34m /\\ \033[0m",
" /\\ \\ ", "\033[34m /\\ \\ \033[0m",
" / \\ ", "\033[34m / \\ \033[0m",
"/__/\\__\\" "\033[34m/__/\\__\\\033[0m"
} }
} }
}; };

62
mycfetch.1 Normal file
View File

@ -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
.

View File

@ -1,23 +1,15 @@
#define _POSIX_C_SOURCE 200112L
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <stdarg.h>
#include <string.h> #include <string.h>
#include <stdbool.h>
#include "config.h" #include "config.h"
#include "defs.h" #include "defs.h"
void die(int code, char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
exit(code);
}
void getuptime(char *buffer, int max_length) void getuptime(char *buffer, int max_length)
{ {
struct timespec uptime; struct timespec uptime;
@ -39,19 +31,15 @@ void getuptime(char *buffer, int max_length)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char **art = NULL; char **art = arts[0].art, *name = argv[1];
if (argc > 2) int ret = 0;
if (name)
{ {
die(1, "usage: %s [artname]\n", argv[0]); bool found = false;
} for (int i = 0; i < sizeof(arts) / sizeof(*arts); ++i)
else if (argc == 2) if (!strcmp(arts[i].name, name))
{ { art = arts[i].art; found = true; break; }
for (int i = 0; i < sizeof(arts)/sizeof(struct art_entry); ++i) if (!found) ret = 69;
if (!strcmp(arts[i].name, argv[1])) { art = arts[i].art; break; }
if (!art) die(1, "Art %s not found\n", argv[1]);
} else
{
art = arts[0].art;
} }
struct utsname uname_buf; struct utsname uname_buf;
@ -64,9 +52,15 @@ int main(int argc, char **argv)
getuptime(uptime, max_uptime_length); getuptime(uptime, max_uptime_length);
uname(&uname_buf); uname(&uname_buf);
printf("%s %s@%s\n", art[0], username, hostname); printf(
printf("%s --\n", art[1]); "%s %s@%s\n"
printf("%s %s %s\n", art[2], uname_buf.sysname, uname_buf.release); "%s --\n"
printf("%s %s\n", art[3], uptime); "%s %s %s\n"
return 0; "%s %s\n",
art[0], username, hostname,
art[1],
art[2], uname_buf.sysname, uname_buf.release,
art[3], uptime
);
return ret;
} }