My slstatus configuration
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

32 行
403 B

  1. #include <err.h>
  2. #include <pwd.h>
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5. #include "util.h"
  6. const char *
  7. gid(void)
  8. {
  9. return bprintf("%d", getgid());
  10. }
  11. const char *
  12. username(void)
  13. {
  14. struct passwd *pw = getpwuid(geteuid());
  15. if (pw == NULL) {
  16. warn("Failed to get username");
  17. return NULL;
  18. }
  19. return bprintf("%s", pw->pw_name);
  20. }
  21. const char *
  22. uid(void)
  23. {
  24. return bprintf("%d", geteuid());
  25. }