fix
This commit is contained in:
parent
135a196f9a
commit
dfa1d3ad24
3 changed files with 44 additions and 5 deletions
33
src/fetch.c
33
src/fetch.c
|
@ -83,3 +83,36 @@ void GetUser(const char *title, const FETCH fetch) {
|
|||
struct passwd *pw = getpwuid(geteuid());
|
||||
printf("%s%s%s%s", fetch.color, title, fetch.font_color, (pw != 0) ? pw->pw_name : "none");
|
||||
}
|
||||
|
||||
void GetUptime(const char *title, const FETCH fetch) {
|
||||
int hours = 0;
|
||||
int mins = 0;
|
||||
|
||||
#ifdef CLOCK
|
||||
struct timespec uptime;
|
||||
clock_gettime(CLOCK, &uptime);
|
||||
|
||||
hours = uptime.tv_sec / 3600;
|
||||
mins = (uptime.tv_sec / 60) - (uptime.tv_sec / 3600 * 60);
|
||||
#endif
|
||||
|
||||
printf("%s%s%s%dh %dm", fetch.color, title, fetch.font_color, hours, mins);
|
||||
}
|
||||
|
||||
void GetArch(const char *title, const FETCH fetch) {
|
||||
printf("%s%s%s%s", fetch.color, title, fetch.font_color, fetch.uts.machine);
|
||||
}
|
||||
|
||||
void GetShell(const char *title, const FETCH fetch) {
|
||||
char *shell = getenv("SHELL");
|
||||
if (shell == NULL)
|
||||
printf("%s%s%s%s", fetch.color, title, fetch.font_color, "none");
|
||||
|
||||
char *splt = strrchr(shell, '/');
|
||||
if (splt == NULL) {
|
||||
printf("%s%s%s%s", fetch.color, title, fetch.font_color, "none");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s%s%s%s", fetch.color, title, fetch.font_color, splt + 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue