diff --git a/CMakeLists.txt b/CMakeLists.txt index 089a7c16b..765bdc552 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1589,6 +1589,7 @@ elseif(WIN32) PRIVATE "cfgmgr32" PRIVATE "winbrand" PRIVATE "propsys" + PRIVATE "secur32" ) elseif(FreeBSD) target_link_libraries(libfastfetch diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 31b5e79c4..fdd74271e 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -63,6 +63,7 @@ void ffPrintTitle(FFTitleOptions* options) FF_FORMAT_ARG(userNameColored, "user-name-colored"), FF_FORMAT_ARG(atColored, "at-symbol-colored"), FF_FORMAT_ARG(hostNameColored, "host-name-colored"), + FF_FORMAT_ARG(instance.state.platform.fullUserName, "full-user-name"), })); } } @@ -170,6 +171,7 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m { yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result"); yyjson_mut_obj_add_strbuf(doc, obj, "userName", &instance.state.platform.userName); + yyjson_mut_obj_add_strbuf(doc, obj, "fullUserName", &instance.state.platform.fullUserName); yyjson_mut_obj_add_strbuf(doc, obj, "hostName", &instance.state.platform.hostName); yyjson_mut_obj_add_strbuf(doc, obj, "homeDir", &instance.state.platform.homeDir); yyjson_mut_obj_add_strbuf(doc, obj, "exePath", &instance.state.platform.exePath); @@ -193,6 +195,7 @@ static FFModuleBaseInfo ffModuleInfo = { {"User name (colored)", "user-name-colored"}, {"@ symbol (colored)", "at-symbol-colored"}, {"Host name (colored)", "host-name-colored"}, + {"Full user name", "full-user-name"}, })) }; diff --git a/src/util/platform/FFPlatform.c b/src/util/platform/FFPlatform.c index cb044f750..25e03650a 100644 --- a/src/util/platform/FFPlatform.c +++ b/src/util/platform/FFPlatform.c @@ -12,6 +12,7 @@ void ffPlatformInit(FFPlatform* platform) ffStrbufInit(&platform->exePath); ffStrbufInit(&platform->userName); + ffStrbufInit(&platform->fullUserName); ffStrbufInit(&platform->hostName); ffStrbufInit(&platform->userShell); diff --git a/src/util/platform/FFPlatform.h b/src/util/platform/FFPlatform.h index 5dd6c0efa..79b749912 100644 --- a/src/util/platform/FFPlatform.h +++ b/src/util/platform/FFPlatform.h @@ -22,6 +22,7 @@ typedef struct FFPlatform FFstrbuf exePath; // The real path of current exe FFstrbuf userName; + FFstrbuf fullUserName; FFstrbuf hostName; FFstrbuf userShell; diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index fbf59d85f..eb9ee450e 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -181,6 +181,8 @@ static void getUserName(FFPlatform* platform, const struct passwd* pwd) user = pwd->pw_name; ffStrbufAppendS(&platform->userName, user); + + if (pwd) ffStrbufAppendS(&platform->fullUserName, pwd->pw_gecos); } static void getHostName(FFPlatform* platform, const struct utsname* uts) diff --git a/src/util/platform/FFPlatform_windows.c b/src/util/platform/FFPlatform_windows.c index 71feae3f3..b78aa8cc7 100644 --- a/src/util/platform/FFPlatform_windows.c +++ b/src/util/platform/FFPlatform_windows.c @@ -9,6 +9,9 @@ #include #include +#define SECURITY_WIN32 1 // For secext.h +#include + static void getExePath(FFPlatform* platform) { wchar_t exePathW[MAX_PATH]; @@ -138,11 +141,16 @@ static void getUserName(FFPlatform* platform) ffStrbufSetS(&platform->userName, userName); else { - wchar_t buffer[128]; + wchar_t buffer[256]; DWORD len = ARRAY_SIZE(buffer); if(GetUserNameW(buffer, &len)) ffStrbufSetWS(&platform->userName, buffer); } + + wchar_t buffer[256]; + DWORD len = ARRAY_SIZE(buffer); + if (GetUserNameExW(NameDisplay, buffer, &len)) + ffStrbufSetWS(&platform->fullUserName, buffer); } static void getHostName(FFPlatform* platform)