slstatus

status monitor
git clone git://git.suckless.org/slstatus
Log | Files | Refs | README | LICENSE

user.c (531B)


      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 "../slstatus.h"
      8 #include "../util.h"
      9 
     10 const char *
     11 gid(const char *unused)
     12 {
     13 	return bprintf("%d", getgid());
     14 }
     15 
     16 const char *
     17 username(const char *unused)
     18 {
     19 	struct passwd *pw;
     20 
     21 	if (!(pw = getpwuid(geteuid()))) {
     22 		warn("getpwuid '%d':", geteuid());
     23 		return NULL;
     24 	}
     25 
     26 	return bprintf("%s", pw->pw_name);
     27 }
     28 
     29 const char *
     30 uid(const char *unused)
     31 {
     32 	return bprintf("%d", geteuid());
     33 }