diff --git a/config.h b/config.h index 8ead843..4b62e0c 100644 --- a/config.h +++ b/config.h @@ -23,6 +23,7 @@ PARAMETR CONFIG[] = { {" pkg ", GetPkg}, {" mem ", GetMem}, {" mod ", GetModel}, + {" host ", GetHostname}, {" ", Blank}, {" ", PrintColors} }; diff --git a/include/fetch.h b/include/fetch.h index 813ac9f..a2c2951 100644 --- a/include/fetch.h +++ b/include/fetch.h @@ -45,5 +45,6 @@ int GetShell(const char *title, const FETCH fetch); int GetPkg(const char *title, const FETCH fetch); int GetMem(const char *title, const FETCH fetch); int GetModel(const char *title, const FETCH fetch); +int GetHostname(const char *title, const FETCH fetch); #endif diff --git a/src/fetch.c b/src/fetch.c index 7f1a7dc..e62fe83 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "fetch.h" #include "config.h" @@ -231,3 +232,12 @@ int GetModel(const char *title, const FETCH fetch) { fclose(fp); 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; +}