Compare commits

...

2 Commits

Author SHA1 Message Date
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
3 changed files with 84 additions and 4 deletions

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

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, one 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,8 +1,11 @@
#define _POSIX_C_SOURCE 200112L
#include <stdio.h> #include <stdio.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include <stdbool.h>
#include "config.h" #include "config.h"
#include "defs.h" #include "defs.h"
@ -29,10 +32,15 @@ void getuptime(char *buffer, int max_length)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char **art = arts[0].art, *name = argv[1]; char **art = arts[0].art, *name = argv[1];
int ret = 0;
if (name) if (name)
{
bool found = false;
for (int i = 0; i < sizeof(arts) / sizeof(*arts); ++i) for (int i = 0; i < sizeof(arts) / sizeof(*arts); ++i)
if (!strcmp(arts[i].name, name)) if (!strcmp(arts[i].name, name))
{ art = arts[i].art; break; } { art = arts[i].art; found = true; break; }
if (!found) ret = 69;
}
struct utsname uname_buf; struct utsname uname_buf;
char hostname[max_hostname_length]; char hostname[max_hostname_length];
@ -54,5 +62,5 @@ int main(int argc, char **argv)
art[2], uname_buf.sysname, uname_buf.release, art[2], uname_buf.sysname, uname_buf.release,
art[3], uptime art[3], uptime
); );
return 0; return ret;
} }