From 55457187d18221e76bd12f0fb2cfab65c49b92fb Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 5 Mar 2019 01:09:01 +0100 Subject: Initial commit --- slstatus/components/user.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 slstatus/components/user.c (limited to 'slstatus/components/user.c') diff --git a/slstatus/components/user.c b/slstatus/components/user.c new file mode 100644 index 0000000..71a0c9d --- /dev/null +++ b/slstatus/components/user.c @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include + +#include "../util.h" + +const char * +gid(void) +{ + return bprintf("%d", getgid()); +} + +const char * +username(void) +{ + struct passwd *pw; + + if (!(pw = getpwuid(geteuid()))) { + warn("getpwuid '%d':", geteuid()); + return NULL; + } + + return bprintf("%s", pw->pw_name); +} + +const char * +uid(void) +{ + return bprintf("%d", geteuid()); +} -- cgit v1.2.3