core: Add user description variable (#248)

This commit is contained in:
Mike Rivnak 2024-03-30 21:06:11 -04:00 committed by GitHub
parent ad8a1e9b10
commit ad41b31135
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -112,11 +112,16 @@ IWidget::SFormatResult IWidget::formatString(std::string in) {
auto uidPassword = getpwuid(getuid());
char* username = uidPassword->pw_name;
char* user_gecos = uidPassword->pw_gecos;
if (!username)
Debug::log(ERR, "Error in formatString, username null. Errno: ", errno);
if (!user_gecos)
Debug::log(WARN, "Error in formatString, user_gecos null. Errno: ", errno);
IWidget::SFormatResult result;
replaceAll(in, "$DESC", std::string{user_gecos ? user_gecos : ""});
replaceAll(in, "$USER", std::string{username ? username : ""});
replaceAll(in, "<br/>", std::string{"\n"});