diff --git a/.suckless/slstatus/components/cpu.o b/.suckless/slstatus/components/cpu.o new file mode 100644 index 0000000..8e1bfc1 Binary files /dev/null and b/.suckless/slstatus/components/cpu.o differ diff --git a/.suckless/slstatus/components/datetime.c b/.suckless/slstatus/components/datetime.c new file mode 100644 index 0000000..5b10daf --- /dev/null +++ b/.suckless/slstatus/components/datetime.c @@ -0,0 +1,20 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include + +#include "../slstatus.h" +#include "../util.h" + +const char * +datetime(const char *fmt) +{ + time_t t; + + t = time(NULL); + if (!strftime(buf, sizeof(buf), fmt, localtime(&t))) { + warn("strftime: Result string exceeds buffer size"); + return NULL; + } + + return buf; +} diff --git a/.suckless/slstatus/components/datetime.o b/.suckless/slstatus/components/datetime.o new file mode 100644 index 0000000..225a048 Binary files /dev/null and b/.suckless/slstatus/components/datetime.o differ diff --git a/.suckless/slstatus/components/disk.c b/.suckless/slstatus/components/disk.c new file mode 100644 index 0000000..e19a693 --- /dev/null +++ b/.suckless/slstatus/components/disk.c @@ -0,0 +1,59 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include + +#include "../slstatus.h" +#include "../util.h" + +const char * +disk_free(const char *path) +{ + struct statvfs fs; + + if (statvfs(path, &fs) < 0) { + warn("statvfs '%s':", path); + return NULL; + } + + return fmt_human(fs.f_frsize * fs.f_bavail, 1024); +} + +const char * +disk_perc(const char *path) +{ + struct statvfs fs; + + if (statvfs(path, &fs) < 0) { + warn("statvfs '%s':", path); + return NULL; + } + + return bprintf("%d", (int)(100 * + (1 - ((double)fs.f_bavail / (double)fs.f_blocks)))); +} + +const char * +disk_total(const char *path) +{ + struct statvfs fs; + + if (statvfs(path, &fs) < 0) { + warn("statvfs '%s':", path); + return NULL; + } + + return fmt_human(fs.f_frsize * fs.f_blocks, 1024); +} + +const char * +disk_used(const char *path) +{ + struct statvfs fs; + + if (statvfs(path, &fs) < 0) { + warn("statvfs '%s':", path); + return NULL; + } + + return fmt_human(fs.f_frsize * (fs.f_blocks - fs.f_bfree), 1024); +} diff --git a/.suckless/slstatus/components/disk.o b/.suckless/slstatus/components/disk.o new file mode 100644 index 0000000..f3bd7bd Binary files /dev/null and b/.suckless/slstatus/components/disk.o differ