slstatus

My fork of https://tools.suckless.org/slstatus/
git clone https://git.inz.fi/slstatus
Log | Files | Refs | README | LICENSE

user.c (464B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <pwd.h>
      3 #include <stdio.h>
      4 #include <sys/types.h>
      5 #include <unistd.h>
      6 
      7 #include "../util.h"
      8 
      9 const char *
     10 gid(void)
     11 {
     12 	return bprintf("%d", getgid());
     13 }
     14 
     15 const char *
     16 username(void)
     17 {
     18 	struct passwd *pw;
     19 
     20 	if (!(pw = getpwuid(geteuid()))) {
     21 		warn("getpwuid '%d':", geteuid());
     22 		return NULL;
     23 	}
     24 
     25 	return bprintf("%s", pw->pw_name);
     26 }
     27 
     28 const char *
     29 uid(void)
     30 {
     31 	return bprintf("%d", geteuid());
     32 }