This commit is contained in:
Your Name 2024-01-03 14:10:52 +03:00
parent 69ddc38152
commit 7ab3e8ef0c
3 changed files with 12 additions and 0 deletions

View File

@ -23,6 +23,7 @@ PARAMETR CONFIG[] = {
{" pkg ", GetPkg}, {" pkg ", GetPkg},
{" mem ", GetMem}, {" mem ", GetMem},
{" mod ", GetModel}, {" mod ", GetModel},
{" host ", GetHostname},
{" ", Blank}, {" ", Blank},
{" ", PrintColors} {" ", PrintColors}
}; };

View File

@ -45,5 +45,6 @@ int GetShell(const char *title, const FETCH fetch);
int GetPkg(const char *title, const FETCH fetch); int GetPkg(const char *title, const FETCH fetch);
int GetMem(const char *title, const FETCH fetch); int GetMem(const char *title, const FETCH fetch);
int GetModel(const char *title, const FETCH fetch); int GetModel(const char *title, const FETCH fetch);
int GetHostname(const char *title, const FETCH fetch);
#endif #endif

View File

@ -5,6 +5,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include "fetch.h" #include "fetch.h"
#include "config.h" #include "config.h"
@ -231,3 +232,12 @@ int GetModel(const char *title, const FETCH fetch) {
fclose(fp); fclose(fp);
return 0; return 0;
} }
int GetHostname(const char *title, const FETCH fetch) {
char hostname[HOST_NAME_MAX + 1];
if (gethostname(hostname, sizeof(hostname)) < 0)
return 1;
printf("%s%s%s%s", fetch.color, title, fetch.font_color, hostname);
return 0;
}